I'm working with a Python backend API that gives me date/time in a string represented as such:
2014-07-21T16:50:34.144Z
What is this format, and how might I use javascript in my Ember app to put that string into a human readable format?
Ember actually includes a library(http://momentjs.com/) for handling dates/times. I created a helper with the following code:
Ember.Handlebars.helper('format-date', function(date) {
return moment(date).format('LLL');
});
Then in my handlebars template I have a call to the helper:
{{format-date dateCreated}}
The helper tag passes the date attribute to the helper, and the moment function handles the formatting. The 'LLL', per the moment.js docs specifies the actual format the date takes. In my case
2014-07-21T16:50:34.144Z
formats into
July 21 2014 9:50 AM
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加