时间格式转换方法
2021-02-07 本文已影响0人
VIAE
//获取当前日期yyyy/mm/dd hh:mm:ss
export function getCurrTime(){
let currDate = new Date();
let year = currDate.getFullYear();
let month = currDate.getMonth() + 1;
let day = currDate.getDate();
let hour = currDate.getHours();
let minute = currDate.getMinutes();
let second = currDate.getMinutes();
return year + "-"+getMakeZero(month)+"-"+getMakeZero(day)+" "+getMakeZero(hour)+":"+getMakeZero(minute)+":"+getMakeZero(second);
}
// 时间补0
function getMakeZero(s) {
return s < 10 ? '0' + s : s;
}
//获取TZ时间戳 2020-12-29T07:09:57.587Z
export function getTZTime(){
let currDate = new Date();
return currDate.toISOString()
}