1.0.0 • Published 2 years ago

pidengdeng v1.0.0

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

安装

npm i bagbag

引入

const dataformat = require('bagbag')

格式化时间

//格式化时间
function format() {
    const dt = new Date();
    const y = dt.getFullYear();
    const m = zero(dt.getMonth() + 1);
    const d = zero(dt.getHours());
    const h = zero(dt.getHours());
    const c = zero(dt.getMinutes());
    const s = zero(dt.getSeconds());

    return `${y}-${m}-${d} ${h}:${c}:${s}`
}

function zero(n){
    return n < 10 ? '0' + n : n
}


module.exports = {
    format
}

转义