Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs getTime()的日期(毫秒)_Angularjs - Fatal编程技术网

Angularjs getTime()的日期(毫秒)

Angularjs getTime()的日期(毫秒),angularjs,Angularjs,我希望以毫秒为单位输出日期,但它不起作用 在HTML文件中,我有: {{product.date_expiration}}://哪个输出==>2018-01-13T12:22:06.165Z {{CurrentDate}}://哪个输出==>“2017-02-10T13:18:58.339Z” 与: 以及: 当我尝试以毫秒为单位获取日期时: {{product.date\u expiration.getTime()}=>不输出任何内容 以及: 似乎date\u expiration不是一个日期对

我希望以毫秒为单位输出日期,但它不起作用

在HTML文件中,我有:

{{product.date_expiration}}://哪个输出==>2018-01-13T12:22:06.165Z

{{CurrentDate}}://哪个输出==>“2017-02-10T13:18:58.339Z”

与:

以及:

当我尝试以毫秒为单位获取日期时:

{{product.date\u expiration.getTime()}=>不输出任何内容

以及:


似乎
date\u expiration
不是一个日期对象。因此
getTime()
函数对它不起作用。我们必须使用一个过滤器将其转换为日期对象,并给我们以毫秒为单位的时间,因为我们不能在角度表达式中使用
date()

var-app=angular.module('myApp',[]);
app.filter('inmillizes',function(){
返回函数(x){
返回新日期(x).getTime();
};
});
应用程序控制器('myCtrl',函数($scope){
$scope.date_expiration=“2018-01-13T12:22:06.165Z”;
$scope.currentDate=新日期();
});

date_expiration:{{date_expiration}以毫秒为单位}

currentDate:{{currentDate.getTime()}}
date\u expiration可能是字符串,而不是日期。
{{{produit.date\u expiration.getTime()}
是问题中的一个输入错误,还是该输入错误是问题的原因!?抱歉,这是个打字错误,这篇文章被编辑了
date_expiration: {type: Date}
{CurrentDate}}: {type: Date}
{{CurrentDate.getTime()}} ==> output 1486733469830