SOURCE

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

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

writeDocument("获取年,月,日,时,分,秒,毫秒-------------");
writeDocument("年: " + oToday.getFullYear());
writeDocument("月: " + oToday.getMonth());
writeDocument("日: " + oToday.getDate());
writeDocument("时: " + oToday.getHours());
writeDocument("分: " + oToday.getMinutes());
writeDocument("秒: " + oToday.getSeconds());
writeDocument("毫秒: " + oToday.getMilliseconds());

writeDocument("设置年,月,日,时,分,秒,毫秒-------------");
var oDate = new Date(2019);

oDate.setFullYear(2020);
writeDocument("年: " + oDate.getFullYear());
oDate.setFullYear(6);
writeDocument("月: " + oDate.getMonth());
console 命令行工具 X clear

                    
>
console