1.1.1 • Published 2 years ago
zhangzhang6 v1.1.1
安装
npm i TimeFormat1
引入
const dataformat = require('TimeFormat');
格式化时间
function format(){
const dt = new Date();
const y = dt.getFullYear();
const m = zero(dt.getMonth()+1);
const d = dt.getDay();
const h = dt.getHours();
const mi = dt.getMinutes();
const s = dt.getSeconds();
return `${y}-${m}-${d} ${h}:${mi}:${s}`
}
转义html符号
function Esp(htmlEsp){
return htmlEsp.replace(/<|>|"|&/g,(match)=>{
switch(match){
case '<':
return '<'
case '>':
return '>'
case '"':
return '$quot;'
case '&':
return '&'
}
})
}
开源许可协议 ISC
1.1.1
2 years ago