解析Javascript日期 [英] Parsing Javascript Date
本文介绍了解析Javascript日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在查看的网站具有以下代码。
A website I am looking at has the following code.
var d = new Date(1362236400000);
此javascript日期对象以某种方式编码以下HTML输出,
This javascript date object somehow encodes the following HTML output,
"2/3/2013 10:00"
有人可以解释一下这种编码吗?我需要制作一个可以处理这些JavaScript数字以重新创建HTML输出的python脚本。谢谢!
Could someone please explain this encoding? I need to make a python script that manipulates those javascript numbers to recreate the HTML output. Thanks!
推荐答案
值是自该纪元以来的毫秒数。在Python中,可以使用 datetime处理.datetime.fromtimestamp()
构造函数:
The value is the number of miliseconds since the epoch. In Python that could be handled with the datetime.datetime.fromtimestamp()
constructor:
>>> import datetime
>>> datetime.datetime.fromtimestamp(1362236400000/1000)
datetime.datetime(2013, 3, 2, 16, 0)
这篇关于解析Javascript日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文