// 時(shí)間轉(zhuǎn)化為時(shí)間戳 11:11
getMillisecond(time) {
const timeArray = time.split(':');
return timeArray[0] * 3600000 + timeArray[1] * 60000;
},
// 時(shí)間戳轉(zhuǎn)化為時(shí)間
dateFormat(fmt, date) {
let ret;
const utc = date.getTimezoneOffset() / 60;
const opt = {
'Y+': date.getFullYear().toString(), // 年
'm+': (date.getMonth() + 1).toString(), // 月
'd+': date.getDate().toString(), // 日
"H+": date.getHours().toString(), // 時(shí)
//'H+': (date.getHours() + utc < 0 ? 24 + date.getHours() + utc : date.getHours() + utc).toString(), // 時(shí)(轉(zhuǎn)UTC時(shí)間)
'M+': date.getMinutes().toString(), // 分
'S+': date.getSeconds().toString() // 秒
// 有其他格式化字符需求可以繼續(xù)添加姐浮,必須轉(zhuǎn)化成字符串
};
for (const k in opt) {
ret = new RegExp('(' + k + ')').exec(fmt);
if (ret) {
fmt = fmt.replace(ret[1], (ret[1].length == 1) ? (opt[k]) : (opt[k].padStart(ret[1].length, '0')));
}
}
return fmt;
}
dateFormat("HH:MM",new Date(xxxxxxx))
// 獲取UTC 時(shí)區(qū)
function timeZoneValue(from) {
const d = String(new Date()).split(' ');
return d[5];
};
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者