var timer = Date.now();console.log(timer);
var timestamp1 = Date.parse(new Date());
var timestamp2 = (new Date()).valueOf();
var timestamp3 = new Date().getTime();
console.log(timestamp1);
console.log(timestamp2);
console.log(timestamp3);
var strtime = '2014-04-23 18:55:49:123'; //把日期转换为时间戳;
var date = new Date(strtime);
console.log(date);
var date = new Date(1577688324100); //把时间戳转换为日期
Y = date.getFullYear() + '-';
M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
D = date.getDate() + ' ';
h = date.getHours() + ':';
m = date.getMinutes() + ':';
s = date.getSeconds();
console.log(Y+M+D+h+m+s);

还没有评论,来说两句吧...