Javascript相当于php的strtotime()? [英] Javascript equivalent of php's strtotime()?
本文介绍了Javascript相当于php的strtotime()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在PHP中,您可以使用 strtotime()
将英文文本datetime描述转换为正确的日期。
In PHP, you can easily convert an English textual datetime description into a proper date with strtotime()
.
在Javascript中有什么类似的东西?
Is there anything similar in Javascript?
推荐答案
我发现本文,并尝试了本教程。基本上,您可以使用date构造函数来解析日期,然后从 getTime()
方法中获取秒数
I found this article and tried the tutorial. Basically, you can use the date constructor to parse a date, then write get the seconds from the getTime()
method
var d=new Date("October 13, 1975 11:13:00");
document.write(d.getTime() + " milliseconds since 1970/01/01");
这是否有效?
这篇关于Javascript相当于php的strtotime()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文