中国标准时间转日期YYYY-MM-DD
程序员文章站
2022-03-30 09:00:58
...
function switchDate(standardTime) {
if (standardTime != "") {
let a = standardTime;
var Month = a.getMonth() + 1;
var MonthDate;
var DayDate = a.getDate();
var Day;
if (Month < 10) {
MonthDate = '0' + Month;
} else {
MonthDate = Month;
}
if (DayDate < 10) {
Day = '0' + DayDate;
} else {
Day = DayDate;
}
var datetime = a.getFullYear() + "-" + MonthDate + "-" + Day;
console.log(datetime)
return datetime
}
}
中国标准时间standardTime = Sat Jan 01 1994 00:00:00 GMT+0800 (中国标准时间) 转之后是datetime = 1994-01-01
上一篇: vue中的watch
下一篇: FTP网络源YUM仓库配置