InvalidPipeArgument:'2017-12-05 05:30:00对于管道'DatePipe'-Safari [英] InvalidPipeArgument: '2017-12-05 05:30:00 for pipe 'DatePipe' - Safari
本文介绍了InvalidPipeArgument:'2017-12-05 05:30:00对于管道'DatePipe'-Safari的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例外
InvalidPipeArgument:'DatePipe'管道的'2017-12-05 05:30:00
InvalidPipeArgument: '2017-12-05 05:30:00 for pipe 'DatePipe'
代码
以下代码在mac机chrome浏览器上运行正常,但在safari中失败:
The following code is working fine on mac machine chrome browser but in safari it fails :
import { Pipe, PipeTransform } from '@angular/core';
import { DatePipe } from '@angular/common';
import * as moment from 'moment';
@Pipe({
name: 'dateCulturePipe',
})
export class dateCulturePipe implements PipeTransform {
transform(value: string) {
if (value) {
value = moment.utc(value).local().format('YYYY-MM-DD HH:mm:ss');
}
return value;
}
}
使用
{{ (item.Date | dateCulturePipe) | date:'dd-MMM-yyyy HH:mm' }}
值
Date
2018-06-01 11:39:41.880
2018-05-25 10:39:54.597
NULL
2018-05-23 09:33:00.000
2018-05-22 13:04:20.190
2018-05-22 11:20:14.530
2018-05-19 11:55:53.750
2018-05-19 11:55:04.117
2018-05-18 11:34:06.190
2018-05-10 11:57:18.507
2018-05-10 11:44:25.893
2018-05-10 11:42:47.467
2018-05-10 11:42:21.197
2018-05-10 11:41:46.363
2018-05-10 11:40:42.483
NULL
NULL
2018-05-04 11:04:00.000
NULL
2018-05-03 11:04:00.000
NULL
已选中-不知道在哪里更改
https://github.com/angular/angular/issues/12334
推荐答案
您可以参考此特定问题
Invalid argument for pipe 'DatePipe' - Safari cannot parse Date offsets
要解决此问题,请替换您的字符串
To fix this, Replace your string
'2017-11-02 00:00:00.000'.replace(/\s/g, "T")
这篇关于InvalidPipeArgument:'2017-12-05 05:30:00对于管道'DatePipe'-Safari的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文