const now = new Date();
const year = now.getFullYear();
const month = (now.getMonth() + 1).toString().padStart(2, '0');
const date = now.getDate().toString().padStart(2, '0');
const hours = now.getHours().toString().padStart(2, '0');
const minutes = now.getMinutes().toString().padStart(2, '0');
const seconds = now.getSeconds().toString().padStart(2, '0');
const weekdays = [ "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
const week = weekdays[now.getDay()]; //星期
const time = `${year}-${month}-${date} ${hours}:${minutes}:${seconds}` //年月日 时分秒
Js获取当前时间的年月日时分秒星期
最新推荐文章于 2024-06-15 17:30:15 发布