Answer the question
In order to leave comments, you need to log in
How to correctly convert a date from UTC to human readable form?
The story is that I get the date: 1462518000
If I slip it into any online converter, we get something like Fri, 06 May 2016 07:00:00 GMT
I write:
I get: 1970-Jan-18 04:15:18 Question: why not the correct date? <p>{{row.dt | date:'yyyy-MMM-dd HH:mm:ss'}}</p>
Answer the question
In order to leave comments, you need to log in
Because unixtime is in seconds, and Date in JS is in milliseconds. Multiply by 1000.
> new Date(1462518000 * 1000)
Fri May 06 2016 10:00:00 GMT+0300 (MSK)
You can look towards the moment js library. Pretty comfortable, pretty simple. There is support for timezone.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question