var today = new Date(); // 获取当前时间var today = new Date(1453094034000);var birthday = new Date('December 17,1995');var birthday = new Date('1995-12-17T03:24:00');var birthday1 = new Date(1995,11,17,3,24,0);birthday1.toLocaleString() // "1995/12/17 上午3:24:00"// 注意: 0-11数字表示1-12月,var a = new Date(2006,5,6) 结果是2006-6-6// 0-6 表示星期几
两种定时器
setInterval 循环执行
window.setInterval(function(){ // do your business},100);
setTimeout 只调用一次
window.setTimeout(function() { // do your business},100);
定时器的取消
clearInterval
var timer1 = setInterval(function(){ clearInterval(timer1);},100);
clearTimeout
var timer2 = setTimeout(function() { clearTimeout(timer2);},100);