AngularJS wrong unix time parse result AngularJS wrong unix time parse result unix unix

AngularJS wrong unix time parse result


Its cause you use seconds not milliseconds.

new Date(1378028575)Fri Jan 16 1970 23:47:08 GMT+0100 (CET)new Date(1378028575000)Sun Sep 01 2013 11:42:55 GMT+0200 (CEST)

from the angular docs:

Date to format either as Date object, milliseconds (string or number) or various ISO 8601 datetime string formats (e.g. yyyy-MM-ddTHH:mm:ss.SSSZ and its shorter versions like yyyy-MM-ddTHH:mmZ, yyyy-MM-dd or yyyyMMddTHHmmssZ). If no timezone is specified in the string input, the time is considered to be in the local timezone.


The other answer isnt quite complete. Since your timestamp is in seconds, not miliseconds, in Angular.js you can do this:

{{1378028575 * 1000 | date:'medium'}}

Knowing seconds * 1000 = miliseconds is one thing. Knowing you can put math in the date expression is another :)