1.0.0 • Published 2 years ago

wjq-time v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

安装

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>')
// 转为结果 &lt;h1 style=&quot;color: red;&quot;&gt;哈哈&lt;/h1&gt;
console.log(dtString)

将特殊字符转义为 HTML

// 调用 toString 对时间进行格式化
const dtHtml = format.toHtml('&lt;h1 style=&quot;color: red;&quot;&gt;哈哈&lt;/h1&gt;')
// 转为结果 <h1 style="color: red;">哈哈</h1>
console.log(dtHtml)

开源协议

ISC