angularjs - Why does angular date filter adding 2 to hour? -
i've created duration timer in angular js, using angular 'date' filter. reason, hour part starting '2' instead of '0'.
i'm using filter this
{{runningduration | date:'hh:mm:ss'}} http://jsfiddle.net/rpg2kill/vndpu/
what doing wrong?
it's because want format date pass difference between dates integer. angular assumes want new date(runningduration).
you can use filter convert date utc(this requires more corner case handling number , date). demo
js
myapp.filter('utc', [function() { return function(date) { if(angular.isnumber(date)) { date = new date(date); } return new date(date.getutcfullyear(), date.getutcmonth(), date.getutcdate(), date.getutchours(), date.getutcminutes(), date.getutcseconds()); } } ]); html
{{runningduration | utc | date:'hh:mm:ss'}}
Comments
Post a Comment