Javascript-将日期格式转换为秒 [英] Javascript - convert date format to seconds

查看:1214
本文介绍了Javascript-将日期格式转换为秒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

需要帮助将此日期格式更改为秒.

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的其他信息可以在以下位置阅读:

Additional information about Date.getDate may be read at: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime

这篇关于Javascript-将日期格式转换为秒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆