问题
I'd Like to generate some unix Timestamp in the future. therefore i use a generator like unixtimestamp.com. But when i use the any generated timestamp for example in a console.log in chrome or firefox it produces not the timestamp from now but a timestamp from 1970.
Example: 1462277206 is the Unix Timestamp for Tue May 3 12:06:46 2016 GMT.
But in the console new Date(1462277206)
returns
Sat Jan 17 1970 23:11:17 GMT+0100 (CET)
.
What am i doing wrong?
Thanks for your help!
Muff
回答1:
JavaScript date/time numbers are milliseconds since The Epoch, not seconds since The Epoch like old-style Unix Epoch values. If you have a value in seconds, multiply by 1000:
new Date(1462277206 * 1000);
来源:https://stackoverflow.com/questions/37001797/unix-timestamp-from-now-outputs-as-1970