JavaScript获取时间戳

无人久伴 提交于 2019-12-05 04:24:50

有时前后端交互需要传递时间戳。获取时间戳的方法如下:

 

  console.log( Date.parse(new Date()) ) // 1574318285000 精确到秒
  console.log( (new Date()).valueOf() ) // 1574318285290 精确到毫秒
  console.log( new Date().getTime()) // 1574318285290 精确到毫秒

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!