1.0.1 • Published 9 months ago

hzh-time v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
9 months ago

安装

、、、 npm install hzh-time 、、、

导入

、、、js const itheima = require("hzh-time"); 、、、

格式化时间

、、、js // 调用 dateFormat 对时间进行格式化 const date = new Date(); const formatDate = itheima.formatTime(date, "yyyy-MM-dd hh:mm:ss"); console.log(formatDate); // 2020-06-21 16:00:00 、、、

转义HTML中的特殊字符

、、、js // 带转换的HTML字符串 const htmlStr = '标签为h1123 ' // 调用 htmlEscape 对字符串进行转义 const str = time.htmlEscape(htmlStr); console.log(str); // 结果 <h1 title="abc">标签为h1<span>123& 、、、

还原HTML中的特殊字符

、、、js // 带转义后的HTML字符串 const str = '<h1 title="abc">标签为h1<span>123&nbsp;</span></h1>' // 调用 htmlUnescape 对字符串进行还原 const htmlStr = time.htmlUnescape(str); console.log(htmlStr); // 结果 标签为h1123  、、、

开源协议

ISC

1.0.1

9 months ago

1.0.0

9 months ago