问题描述
需要帮助将此日期格式更改为秒.
Need help to change this date format to seconds.
<div class="calendar" data-fixeddate="July 16, 2017 00:05 am">...</div>
JS:
想要获取此日期格式以将该值转换为秒.
want to get this date format to convert this value to seconds.
请让我知道我们可以使用Java脚本还是JQuery进行转换?
Please let me know whether we can convert using Javascript or JQuery?
谢谢
推荐答案
在浏览器控制台中尝试以下操作:
Try this in your browser console:
new Date('July 16, 2017 00:05 am').getTime() / 1000
Date.getTime
返回以毫秒为单位的日期,除以1000得到秒.
Date.getTime
returns the date in milliseconds, divide by 1000 to get seconds.
有关Date.getDate
的其他信息可以在以下位置阅读: https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime
Additional information about Date.getDate
may be read at: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime
这篇关于Javascript-将日期格式转换为秒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!