Reputation: 527
How to get this format of time from the angular2 typescript?
2016-9-25T05:10:04.106Z
I tried googling could not find a clean way of doing it.
This way in TS gives the fallowing outputs,
Date.now(); //1474804051687 timestamp
new Date; //Sun Sep 25 2016 17:14:45 GMT+0530
In JS we can get that format by
new Date; //2016-9-25T05:10:04.106Z
What am i missing,Can anyone guide me to overcome this problem?
Upvotes: 0
Views: 84
Reputation: 151
In angular you can directly use in-bulit date filter just like in angular 1.X version
https://docs.angularjs.org/api/ng/filter/date
Ref: https://auth0.com/blog/angular2-series-working-with-pipes/
hope this helps :)
Upvotes: 0
Reputation: 9780
Just create a date object and call toISOString()
method on date object
Upvotes: 3