SOURCE

function writeDocument(variable) 
{
document.write(variable + "<br/>");
} 

writeDocument("定义一个时间对象-----------------------------------------------");
var oToday=new Date();
writeDocument(oToday);

writeDocument("获取时间对象:年、月、日、时、分、秒----------------------------------------------");
writeDocument("年:"+oToday.getFullYear());
writeDocument("月:"+(+oToday.getMonth()+1));
writeDocument("日:"+oToday.getDate());
writeDocument("时:"+oToday.getHours());
writeDocument("分:"+oToday.getMinutes());
writeDocument("秒:"+oToday.getSeconds());

writeDocument("设置时间对象:年、月、日、时、分、秒(2020-12-29 20:20:17 999)------------------------");
var oMybirthday=new Date();
oMybirthday.setFullYear(2020);
oMybirthday.setMonth(11);
oMybirthday.setDate(29);
oMybirthday.setHours(20);
oMybirthday.setMinutes(20);
oMybirthday.setSeconds(17,999);
writeDocument(oMybirthday);

writeDocument("获取星期几-----------------------------------------------");
//writeDocument("今天是星期"+oToday.getDay());

var week=["星期天","星期一","星期二","星期三","星期四","星期五","星期六"];
writeDocument("今天是"+week[oToday.getDay()]);

writeDocument("设置时间对象:年、月、日、时、分、秒(2020-12-29 20:20:17 999)------------------------");
var oMybirthday=new Date();
oMybirthday.setFullYear(2019);
oMybirthday.setMonth(5);
oMybirthday.setDate(1);
oMybirthday.setHours(15);
oMybirthday.setMinutes(59);
oMybirthday.setSeconds(59,99);
writeDocument(oMybirthday);
console 命令行工具 X clear

                    
>
console