Using the javascript error console in chrome:

new Date()
Sat Apr 19 2014 21:31:35 GMT+0200 (W. Europe Summer Time)

new Date().getTime()
1397935905577

gives me a time stamp of now

it is a little hard to show you because time keeps moving (someone stop it for a sec please)

new Date(1397935465774);//a current time
Sat Apr 19 2014 21:24:25 GMT+0200 (W. Europe Summer Time)


new Date(1397935471308)//a current time plus 86400
Sat Apr 19 2014 21:24:31 GMT+0200 (W. Europe Summer Time)

because 24hrs is made of 86400 seconds, like this:

(new Date().getTime())+86400
1397936020170

but there is only like ten minutes (ish I can't tell time very well) difference

new Date(new Date().getTime())
Sat Apr 19 2014 21:33:40 GMT+0200 (W. Europe Summer Time)



new Date((new Date().getTime())+86400)
Sat Apr 19 2014 21:31:45 GMT+0200 (W. Europe Summer Time)

Why?

有帮助吗?

解决方案

The integer value is in milliseconds, try adding 86400000.

其他提示

new Date().getTime() gives you time in milliseconds, not seconds!

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top