function writeDocument(variable) {
document.write(variable + "<br/>");
}
writeDocument("定义一个时间对象---------------------------------------------")
var oToday=new Date();
writeDocument(oToday);
writeDocument("获取时间对象的年,月,日,时,分,秒---------------------------------------------")
writeDocument("年:"+oToday.getFullYear());
writeDocument("月:"+(oToday.getMonth()+1));
writeDocument("日:"+oToday.getDay());
writeDocument("时:"+oToday.getHours());
writeDocument("分:"+oToday.getMinutes());
writeDocument("秒:"+oToday.getSeconds());
writeDocument("设置时间对象的年,月,日,时,分,秒--(2019-6-11 11:30:58 888)-------------------------------------------")
var oMyBrithday=new Date();
oMyBrithday.setFullYear(2019);
oMyBrithday.setMonth(5);
oMyBrithday.setDate(1);
oMyBrithday.setHours(11);
oMyBrithday.setMinutes(30);
oMyBrithday.setSeconds(58,888);
writeDocument(oMyBrithday);
writeDocument("获取星期几-------------------------------------------")
writeDocument("今天是星期"+oToday.getDay());
var week=["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]
writeDocument("今天是"+week[oToday.getDay()]);
writeDocument("请你打印'今天是2022年3月22日 星期三 8:55'------------------")
//new Date(year, monthIndex [22, day [8, hours [55, minutes ]]]);
writeDocument
var a=new Date();
a.setFullYear(2022);
a.setMonth(3);
a.setDate(22);
a.setHours(8);
a.setMinutes(55);
writeDocument("今天是"+a.getFullYear()+"年"+a.getMonth()+"月"+a.getDate()+"日"+week[a.getDay()]+a.getHours()+":"+a.getMinutes());
console