setInterval(() => {
var dt = new Date();
var y = dt.getFullYear();
var mt = dt.getMonth() + 1;
if (mt < 10) {
mt = `0${mt}`;
}
var day = dt.getDate();
if (day < 10) {
day = `0${day}`;
}
var h = dt.getHours(); //获取时
if (h < 10) {
h = `0${h}`;
}
var m = dt.getMinutes(); //获取分
if (m < 10) {
m = `0${m}`;
}
var s = dt.getSeconds(); //获取秒
if (s < 10) {
s = `0${s}`;
}
var week = dt.getDay();
if (week === 0) {
week = "周日";
} else if (week === 1) {
week = "周一";
} else if (week === 2) {
week = "周二";
} else if (week === 3) {
week = "周三";
} else if (week === 4) {
week = "周四";
} else if (week === 5) {
week = "周五";
} else if (week === 6) {
week = "周六";
}
this.myTime =
y + "-" + mt + "-" + day + " " + h + ":" + m + ":" + s + " " + week;
}, 1000);
|