// 1547287516587 表示1970年1月1日距离现在所过去的毫秒
// 1547287516587 — >时间 new Date(時間戳)
// console.log(+date);
// 1. 时间戳就表示一个时间 是一个时间的数字的表示
// 2. 时间戳作用:计算两个时间的差
// 2.1 计算一段代码的执行时间
// date是开始的时间
// var start = new Date()
// var sum = 0;
// for(var i = 1; i <= 100000000; i++) {
// sum += i;
// }
// console.log(sum);
// // end是结束的时间
// var end = new Date();
// console.log(end - start);
// 2.2 倒计时
// 计算下载距离过年还有多久 过年那天: 2019年2月5日 0时 0分 0秒
var now = new Date();
var future = new Date(‘2019-02-05 00:00:00’);
// 距离过年还有的秒数
var time = parseInt((future - now)/1000);
// 1天
var day = parseInt(time/3600/24);
console.log(day);
// 小时 1小时 = 60分钟 = 3600
var hour = parseInt(time/3600) % 24;
console.log(hour);
// 分钟 = 60秒钟 只显示不足60的部分
var minute = parseInt(time / 60 ) % 60;
console.log(minute);
// 秒钟 不足60
var second = time % 60;
console.log(second);
document.write(‘
’);
document.write(‘距离过年还有:’+ day+‘天’ + hour + ‘小时’ + minute + ‘分钟’ + second + ‘秒钟’)
document.write(‘’);