// 一天后的时间转换 var
date =
new
Date(
'2018-02-16');
var
last =
24 *
60 *
60 *
1000;
var
time1 =
date.
getTime();
var
news =
time1 +
last;
console.
log(
time1);
// 1518739200000
function
timestampToTime(
timestamp) { var
date =
new
Date(
timestamp);
//时间戳为10位需*1000,时间戳为13位的话不需乘1000 Y =
date.
getFullYear() +
'-';
M = (
date.
getMonth()+
1 <
10 ?
'0'+(
date.
getMonth()+
1) :
date.
getMonth()+
1) +
'-';
D =
date.
getDate();
return
Y+
M+
D;
} console.
log(
timestampToTime(
news));
//2018-02-17