if 语句
Date 日期时间操作
字符 charAt
let d1 = new Date();
/*console.log(d.getFullYear());
console.log(d.getMonth() + 1);
console.log(d.getDate());
console.log(d.getDay());
console.log(d.getHours());
console.log(d.getMinutes());
console.log(d.getSeconds());*/
//指定时间
// d = new Date("2001-06-23 8:45:39");
// 20天后的日期时间
//setTime 设置时间; getTime 获取时间
/*d.setTime(d.getTime() + (1000 * 60 * 60 * 24 * 20));
console.log(d.getFullYear());
console.log(d.getMonth() + 1);
console.log(d.getDate());
console.log(d.getDay());*/
//if else if 语句
let d = new Date("2001-06-23");
let info = "今天星期:";
if (d.getDay() == 1) {
info = info + "一";
} else if (d.getDay() == 2) {
info = info + "二";
} else if (d.getDay() == 3) {
info = info + "三";
} else if (d.getDay() == 4) {
info = info + "四";
} else if (d.getDay() == 5) {
info = info + "五";
} else if (d.getDay() == 6) {
info = info + "六";
} else {
info = info + "日";
}
console.log(info)
//字符 charAt
console.log(`今日是:星期${"日一二三四五六".charAt(d.getDay())}`)
//返回的时间戳
let d2 = Date.now();
console.log(d2);