SOURCE

var d = new Date();
console.log(d)
var myDay = d.getDate();
console.log(myDay)
var myMonth = d.getMonth() + 1;
console.log(myMonth)
var myYear = d.getFullYear();
console.log(myYear)
document.write("今天是" + myYear + "年" + myMonth + "月" + myDay + "日" + "<br/>");

var d = new Date();
var time = d.getHours();
if (time < 12)
{
    document.write("早上好!");    //如果小时数小于12则输出“早上好!”
}
else if (time >= 12 && time < 18)
{
    document.write("下午好!");    //如果小时数大于等于12并且小于18,输出“下午好!”
}
else
{
    document.write("晚上好!");    //如果上面两个条件都不符合,则输出“晚上好!”
}
console 命令行工具 X clear

                    
>
console