UNPKG

itkun-tools

Version:

提供了格式化时间,HtmlEscape相关的功能

23 lines (18 loc) 499 B
//1.定义格式化时间的方法 function dateFormat(dtStr){ const dt=new Date(dtStr) const y= padZer0(dt.getFullYear()) const m=padZer0(dt.getMonth()+1) const d=padZer0(dt.getDate()) const hh=padZer0(dt.getHours()) const mm=padZer0(dt.getMinutes()) const ss=padZer0(dt.getSeconds()) return `${y}-${m}-${d} ${hh}:${mm}:${ss}` } //定义补零的函数 function padZer0(n){ return n>9?n:'0'+n } module.exports={ dateFormat }