Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
204 views
in Technique[技术] by (71.8m points)

javascript - 格式AngularJS中的日期时间(Format Date time in AngularJS)

How do I properly display the date and time in AngularJS?(如何在AngularJS中正确显示日期和时间?)

The output below shows both the input and the output, with and without the AngularJS date filter:(下面的输出显示输入和输出,有和没有AngularJS日期过滤器:) In: {{v.Dt}} AngularJS: {{v.Dt | date:'yyyy-MM-dd HH:mm:ss Z'}} This prints:(这打印:) In: 2012-10-16T17:57:28.556094Z AngularJS: 2012-10-16T17:57:28.556094Z The desired display format is 2010-10-28 23:40:23 0400 or 2010-10-28 23:40:23 EST(所需的显示格式为2010-10-28 23:40:23 04002010-10-28 23:40:23 EST)   ask by bsr translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Your code should work as you have it see this fiddle .(您的代码应该正常工作,因为它看到这个小提琴 。)

You'll have to make sure your v.Dt is a proper Date object for it to work though.(你必须确保你的v.Dt是一个合适的Date对象,但它可以工作。) {{dt | date:'yyyy-MM-dd HH:mm:ss Z'}} or if dateFormat is defined in scope as dateFormat = 'yyyy-MM-dd HH:mm:ss Z':(或者如果dateFormat在范围内定义为dateFormat ='yyyy-MM-dd HH:mm:ss Z':) {{dt | date:dateFormat }}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.8k users

...