码迷,mamicode.com
首页 > Web开发 > 详细

js得到时间戳(10位数)

时间:2018-12-15 17:14:06      阅读:791      评论:0      收藏:0      [点我收藏+]

标签:lock   logs   log   技术分享   valueof   tool   时间   UNC   func   

 
技术分享图片
//从1970年开始的毫秒数然后截取10位变成 从1970年开始的秒数
function timest() {
  var tmp = Date.parse( new Date() ).toString();
  tmp = tmp.substr(0,10);
  return tmp;
}
技术分享图片

 

技术分享图片
js 时间戳

var ts = Date.parse(new Date());
// ts 得到永远 xxx000  1493269366000  毫秒部分以000表示

得到具体的毫秒:
var ts = (new Date()).valueOf(); //1280977330748
    ts = new Date().getTime();   // 同上

// 得到10位数
    ts = Math.round(new Date().getTime()/1000).toString();
技术分享图片

 

 

js得到时间戳(10位数)

标签:lock   logs   log   技术分享   valueof   tool   时间   UNC   func   

原文地址:https://www.cnblogs.com/shaozhu520/p/10123764.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!