<!DOCTYPE html> <html> <head lang="en"><meta charset="UTF-8"><title></title><script>/*var td=new Date(2017,9,11);alert(td);*/// var td=new Date();// alert(td.getTime());//设计一个定时器---例如:设计日历setTimeout(dat,3000);//3000毫秒,3秒。一次性定时器,调用dat方法,不要()setInterval(dat,1000);//每秒跳一次function dat(){document.body.innerHTML="";var t=new Date();document.write("<h1>"+t.getFullYear()+"年"+(t.getMonth()+1)+"月"+ t.getDate()+"日</h1>");document.write("<h2>今天星期"+ t.getDay()+"</h2>")document.write("<h3>"+ t.getHours()+"时"+ t.getMinutes()+"分"+ t.getSeconds()+"秒");}</script> </head> <body οnlοad="dat()"></body> </html>