Parse A Date From A Timestamp
Last updated
Was this helpful?
Last updated
Was this helpful?
If you are given a timestamp () and you try to parse it with , you are going to get a suprising result.
1970? I was expected something more in the current millenia.
This is because JavaScript's new Date()
expects a timestamp to be in milliseconds. Passing in a seconds representation of a timestamp, when it should be milliseconds, is going to result in a time pretty near the original Unix epoch.
Instead what you need to do is multiple that seconds value by 1000
to get it in terms of milliseconds.
Also, notice that if I run without any argument, it provides the current timestamp in milliseconds.