export function dataFmt(time, format) {
const fmt = format || 'yyyy-MM-dd HH:mm:ss'
var t = new Date(time);
var tf = function(i) {
return (i < 10 ? '0' : '') + i
};
return fmt.replace(/yyyy|MM|dd|HH|mm|ss/g, function(a) {
switch (a) {
case 'yyyy':
return tf(t.getFullYear());
break;
case 'MM':
return tf(t.getMonth() + 1);
break;
case 'mm':
return tf(t.getMinutes());
break;
case 'dd':
return tf(t.getDate());
break;
case 'HH':
return tf(t.getHours());
break;
case 'ss':
return tf(t.getSeconds());
break;
}
})
}
标准UTC时间格式转化字符串年月日时分秒日期
最新推荐文章于 2024-06-07 07:30:00 发布