ith-tools
Version:
提供了格式化时间,HTMLEscape相关功能
22 lines (18 loc) • 507 B
JavaScript
//时间格式化
function dataformat(datastr) {
const dt = new Date(datastr);
const y = padZero(dt.getFullYear());
const m = padZero(dt.getMonth() + 1);
const d = padZero(dt.getDate());
const hh = padZero(dt.getHours());
const mm = padZero(dt.getMinutes());
const ss = padZero(dt.getSeconds());
return y + '-' + m + '-' + d + ' ' + hh + ':' + mm + ':' + ss;
}
//定义补0函数
function padZero(n) {
return n > 9 ? n : '0' + n;
}
module.exports = {
dataformat
}