安装
npm install mytools-utils
导入
const mytools = require('mytools-utils')
格式化时间
//调用dateFormat对时间进行格式化
const dtStr = mytools.dateFormat(new Date())
//结果 2022-06-06 17:45:48
console.log(dtStr)
转义 HTML 中的特殊字符
//带转换的HTML字符串
const htmlStr = '<h1 title = 'abc'>这是一个h1标签</h1>'
//调用htmlEscape方法进行转换
const str = htmlStr.htmlEscape(htmlStr);
//转换的结果:<h1 class = "dorothy">这是一个h1标签<span></span></h1>
## 还原HTML中的特殊字符
```js
//带还原的字符串
const str1 = mytools.htmlUnescape(str)
//输出的结果
console.log(str1)
开源协议
ISC