Reputation: 3825
I am using backend as Tomcat which gives me timestamp as follows :-
1448966450000
If I use the website to convert this time to datetime it gives me something like below :-
1448966450000 -> Wed, 02 Dec 47885 00:33:20 GMT
But when I use a Filter for AngularJS it gives me something like this:-
{{1448966450000 | date: "MMM dd,yyyy '@' hh:mma"}} -> Dec 01,2015 @ 04:10PM
I am living at India and according to IST the time which I receive with the filter is pretty wrong. I am not able to understand where the problem lies.
NOTE: Date Shown by angular is wrong while the former one is the correct one.
Upvotes: 1
Views: 470
Reputation: 1163
Take a look at your timestamp, your site needs timestamp in seconds, but angular filter accepts milliseconds, so you need to multiply your timestamp in filter on 1000, you need to enter 1448966450000000, not 1448966450000
Check the timezone: add timezone to output format (Z)
If timezone is not suitable for you, set preferred timezone
{{1448966450000 | date: "MMM dd,yyyy '@' hh:mma" : '+0530'}}
For more information see https://docs.angularjs.org/api/ng/filter/date
Upvotes: 1
Reputation: 940
The timestamp you are using is in milliseconds since 1/1/1970 The angular filter does it right. The website you test it wants the timestamp in seconds.
Upvotes: 0