SOURCE

function writeDocument(variable){
    document.write(variable + "<br/>");
}
document.write('定义一个时间对象-------------------------------<br/>');
var oToday = new Date();
document.write(oToday + "<br/>");

document.write('获取时间对象的年,月,日,时,分,秒-------------------------------<br/>');
document.write("年:"+oToday.getFullYear() + "<br/>");
document.write("月:"+(oToday.getMonth()+1) + "<br/>");
document.write("日:"+oToday.getDate() + "<br/>");
document.write("时:"+oToday.getHours() + "<br/>");
document.write("分:"+oToday.getMinutes() + "<br/>");
document.write("秒:"+oToday.getSeconds() + "<br/>");

document.write('设置时间对象的年,月,日,时,分,秒(2019-6-1 15:59:59:99)---------<br/>');
var oMyBirthday = new Date();
oMyBirthday.setFullYear(2019);
oMyBirthday.setMonth(6);
oMyBirthday.setDate(1);
oMyBirthday.setHours(15);
oMyBirthday.setMinutes(59);
oMyBirthday.setSeconds(59,99);
document.write(oMyBirthday + "<br/>");

document.write('获取星期几------------------<br/>');
document.write("今天是星期"+oToday.getDate() + "<br/>");

var week =["星期天","星期一","星期二","星期三","星期四","星期五","星期六"];

document.write("今天是"+week[oToday.getDay()] + "<br/>");

document.write("请你打印" + "<br/>");
console 命令行工具 X clear

                    
>
console