hzh-time

1.0.1 • Public • Published

安装

、、、 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

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i hzh-time

      Weekly Downloads

      2

      Version

      1.0.1

      License

      ISC

      Unpacked Size

      3.22 kB

      Total Files

      6

      Last publish

      Collaborators

      • hzhsb12138