-1

When I output the following code to console:

console.log(new Date().getTime());

It says this:

1382888243791

When I convert that code using an online converter like this http://www.onlineconversion.com/unix_time.htm I get this:

Sun, 25 Dec 45791 23:16:31 GMT

Obviously... there is a problem here. The biggest problem being the year of 45791!

How can I properly generate a date in javascript?

4

1 回答 1

1

您使用的转换器必须在大纪元(1970 年 1 月 1 日格林威治标准时间午夜)后几秒钟内工作。JavaScript 自大纪元以来以毫秒为单位工作,因此除以 1000。

于 2013-10-27T15:41:44.580 回答