1.1.1 • Published 2 years ago

yangyang6 v1.1.1

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

安装

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