var str = getIntv("2018-02-08");
function getIntv(time) {
var end = new Date(time);
var now = new Date();
var timer = end - now;
var day = Math.floor(timer / (1000 * 60 * 60 * 24));
var timer1 = timer % (1000 * 60 * 60 * 24);
var hour = Math.floor(timer1 / (1000 * 60 * 60));
var timer2 = timer1 % (1000 * 60 * 60);
var min = Math.floor(timer2 / (1000 * 60));
var timer3 = timer2 % (1000 * 60);
var sec = Math.floor(timer3 / 1000);
return ("距" + time + "还有" + day + "天" + hour + "小时" + min + "分钟" + sec + "秒");
}
console.log(str);
网友评论