时间: 2020-09-9|tag:41次围观|0 条评论

function formatDate(now) {     var y = now.getFullYear();    var m = now.getMonth() + 1; // 注意js里的月要加1     var d = now.getDate();    var h = now.getHours();     var m = now.getMinutes();     var s = now.getSeconds();    return y + "-" + m + "-" + d + " " + h + ":" + m + ":" + s; } var nowDate = new Date(2016, 5, 13, 19, 18, 30, 20);console.log(nowDate.getTime()); // 获得当前毫秒数: 1465816710020console.log(formatDate(nowDate));

文章转载于:https://www.jianshu.com/p/ac9032355d69

原著是一个有趣的人,若有侵权,请通知删除

本博客所有文章如无特别注明均为原创。
复制或转载请以超链接形式注明转自起风了,原文地址《js时间戳、毫秒格式化
   

还没有人抢沙发呢~