// 获取时间
var getDay=(day)=> {
switch (day) {
case 0:
return '星期天';
case 1:
return '星期一';
case 2:
return '星期二';
case 3:
return '星期三';
case 4:
return '星期四';
case 5:
return '星期五';
case 6:
return '星期六';
}
}
const formatTime = () => {
// let date=moment().format()
var date = new Date()
const year = date.getFullYear()
const month = date.getMonth() + 1
const day = date.getDate()
const hour = date.getHours()
const minutes = date.getMinutes()
const seconds = date.getSeconds()
const xin=date.getDay()
return year + '年' + (month < 10 ? '0' + String(month) : String(month)) + '月' + day + '日' + ' (' + getDay(xin) + ') ' + (hour < 10 ? '0' + String(hour) : String(hour)) + '时' + (minutes < 10 ? '0' + String(minutes) : String(minutes)) + '分' + (seconds < 10 ? '0' + String(seconds) : String(seconds)) + '秒';
// return date
}
获取当下时间的星期,日期,时分秒
最新推荐文章于 2024-07-18 15:48:23 发布