1.0.0 • Published 2 years ago
wjq-time v1.0.0
安装
npm install wjq-time
导入
const format = require('./wjq-time');
格化时间的功能
// 调用 initTime 对时间进行格式化
const dtStr = format.initTime(new Date())
// 结果 2022-9-08 11:32:53
console.log(dtStr)
转义 HTML 中的特殊字符
// 调用 toString 对时间进行格式化
const dtString = format.toString('<h1 style="color: red;">哈哈</h1>')
// 转为结果 <h1 style="color: red;">哈哈</h1>
console.log(dtString)
将特殊字符转义为 HTML
// 调用 toString 对时间进行格式化
const dtHtml = format.toHtml('<h1 style="color: red;">哈哈</h1>')
// 转为结果 <h1 style="color: red;">哈哈</h1>
console.log(dtHtml)
开源协议
ISC
1.0.0
2 years ago