UNPKG

lxyyy

Version:

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

19 lines (15 loc) 375 B
function dateFormat(date) { var yy = date.getFullYear() var mm = date.getMonth() var dd = date.getDate() var h = addZero(date.getHours()) var m = addZero(date.getMinutes()) var s = addZero(date.getSeconds()) return `${yy}-${mm}-${dd} ${h}:${m}:${s}` } function addZero(num) { return num > 9 ? num : '0' + num } module.exports = { dateFormat }