时间类:new Date()
> 获取当前时间年月日 2024-04-15 12:52:06
export function getNowFormatDate() {
let stamp = new Date().getTime() + 8 * 60 * 60 * 1000;
let beijingTime = new Date(stamp).toISOString().replace(/T/, ' ').replace(/\..+/, '').substring(0, 19);
return beijingTime
}
> Date 对象转换日期格式 'Wed Apr 03 2024 11:50:00 GMT+0800 (中国标准时间)' 转 2024-04-03 11:50:00
export function toFormatDate(date: string) {
let stamp = new Date(date).getTime() + 8 * 60 * 60 * 1000;
let beijingTime = new Date(stamp).toISOString().replace(/T/, ' ').replace(/\..+/, '').substring(0, 19);
return beijingTime
}