格式AngularJS中的日期时间 [英] Format Date time in AngularJS

查看:174
本文介绍了格式AngularJS中的日期时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在AngularJS中正确显示日期和时间?

How do I properly display the date and time in AngularJS?

下面的输出显示输入和输出,有和没有AngularJS日期过滤器: / p>

The output below shows both the input and the output, with and without the AngularJS date filter:

In: {{v.Dt}}  
AngularJS: {{v.Dt | date:'yyyy-MM-dd HH:mm:ss Z'}}

这打印:

In: 2012-10-16T17:57:28.556094Z 
AngularJS: 2012-10-16T17:57:28.556094Z

所需的显示格式为
2010-10-28 23:40:23 0400 2010-10-28 23:40:23 EST

推荐答案

v.Dt可能不是Date()对象。

v.Dt is likely not a Date() object.

请参阅 http://jsfiddle.net/southerd/ xG2t8 /

但在您的控制器中:

scope.v.Dt = Date.parse(scope.v.Dt);

这篇关于格式AngularJS中的日期时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆