itheima-tools-lgx
Version:
提供了格式化时间、HTML Escape相关的功能-离歌笑
21 lines (19 loc) • 499 B
JavaScript
//格式化时间的方法
function dateFormat(dataStr){
const dt = new Date();
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}`;
}
//补零的方法
function padZero(n)
{
return n > 9 ? n: '0'+n;
}
module.exports = {
dateFormat
}