1.0.0 • Published 1 year ago

zyq-format-time v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

用于格式化时间

格式化字符转义

Y-年 M-月 D-日 h-时 m-分 s-秒 ms-毫秒

安装

npm 安装 npm i zyq-format-time

yarn 安装 yarn add zyq-format-time

当前时间格式化

let time = require('./src/format')

// nowFormat()接收两个参数,第一个是时间格式化字符串,第二个是是否限制为12小时制,若为true则表示显示12小时制

console.log(time.nowFormat('YYYY-MM-DD hh-mm-ss-ms')) // 输出:2023-01-28 00:09:51:446
console.log(time.nowFormat('YYYY-MM-DD hh-mm-ss')) // 输出:2023-01-28 00:09:51
console.log(time.nowFormat('YYYY-MM-DD')) // 输出:2023-01-28
console.log(time.nowFormat('YYYY-MM-DD hh-mm-ss-ms'), true) // 输出:2023-01-27 1:23:51 PM

获取当前时间戳

let time = require('./src/format')

console.log(time.now()) // 输出:1674836552207

开源协议

ISC