2

我使用的JavaScript 库将用户登录时间表示为长整数:

1325982833403

如何将其转换为 datejs 库可以理解的 DateTime ('MM/dd/yyyy hh:mm tt') 值?

4

2 回答 2

2

使用日期构造函数:

var date = new Date(1325982833403*1000);

该数字是 Unix 时间戳,谷歌了解更多信息,以及转换技术

于 2012-01-08T00:48:23.627 回答
1

It's a UNIX timestamp; an extremely useful representation of a moment in time.

Unix time, or POSIX time, is a system for describing instants in time, defined as
the number of seconds elapsed since midnight Coordinated Universal Time (UTC) of
Thursday, January 1, 1970 ...

(http://en.wikipedia.org/wiki/Unix_time)

In practice, with this particular library (http://www.datejs.com/), use:

<script src="http://datejs.googlecode.com/files/date.js" type="text/javascript"></script>
<script type="text/javacript">
    var mydate = Date(1325982833403);
</script>
于 2012-01-08T01:05:08.787 回答