zhangzhang6

1.1.1 • Public • Published

安装

npm i TimeFormat1

引入

const dataformat = require('TimeFormat');

格式化时间

function format(){
    const dt = new Date();
    const y = dt.getFullYear();
    const m = zero(dt.getMonth()+1);
    const d = dt.getDay();
    const h = dt.getHours();
    const mi = dt.getMinutes();
    const s = dt.getSeconds();
    return `${y}-${m}-${d} ${h}:${mi}:${s}`
}

转义html符号

function Esp(htmlEsp){
    return htmlEsp.replace(/<|>|"|&/g,(match)=>{
        switch(match){
            case '<':
                return '&lt;'
            case '>':
                return '&gt;'
            case '"':
                return '$quot;'
            case '&':
                return '&amp'
        }
    })
}

开源许可协议 ISC

Package Sidebar

Install

npm i zhangzhang6

Weekly Downloads

1

Version

1.1.1

License

ISC

Unpacked Size

2.05 kB

Total Files

5

Last publish

Collaborators

  • jiyue