angularjs date filter not formatting my json value -
i have service returns json so:
"results":[{"id":"1","somedate":"2/19/2013 10:34:04 pm"}
when seek format using binding, doesnt work - displays string above:
{{values.somedate| date:'mediumtime' }}
however, works if pass in format:
{{ '1997-03-01t00:00:00+01:00' | date:'mediumtime'}}
what best way prepare this?
as mentioned in comments charlietfl, clean alternative update service homecoming date format compatible built-in angular filters.
however, if not possible, set custom filter parse dates.
a (very small) library recommend moment.js: http://momentjs.com/
the next illustration blog post on how wrap moment.js in custom angular filter: http://www.34m0.com/2012/07/angularjs-user-friendly-date-display.html
angular.module('mymodule'). filter('fromnow', function() { homecoming function(datestring) { homecoming moment(new date(datestring)).fromnow() }; });
this used like:
{{ reply.createddate | fromnow }}
angularjs
No comments:
Post a Comment