DAILY DOCDAILY DOC
Rust
Node
Notes
Ubuntu
Leetcode
  • it-tools
  • excalidraw
  • linux-command
Rust
Node
Notes
Ubuntu
Leetcode
  • it-tools
  • excalidraw
  • linux-command
  • node

    • NODE
    • parseArgs
    • compose
    • date-format
    • dayjs
    • encrypt
    • env-cmd
    • glob
    • Koa 洋葱模型
    • lodash
    • logger
    • log4js
    • mongod
    • nanoid
    • node-red
    • node-stream
    • node:test
    • nodemailer
    • nodemon
    • nodered
    • parse-curl
    • pm2
    • toml
    • ws
    • yargs
    • zx

dayjs

npm install dayjs

格式化占位符

var dayjs = require('dayjs')
//import dayjs from 'dayjs' // ES 2015
dayjs().format("YYYY-MM-DD HH:mm:ss")
dayjs().diff(dayjs('2012'),'year'),// diff year

格式化占位符
输入例子详情
YY18两位数的年份
YYYY2018四位数的年份
M1-12月份,从 1 开始
MM01-12月份,两位数
MMMJan-Dec缩写的月份名称
MMMMJanuary-December完整的月份名称
D1-31月份里的一天
DD01-31月份里的一天,两位数
H0-23小时
HH00-23小时,两位数
h1-12小时, 12 小时制
hh01-12小时, 12 小时制, 两位数
m0-59分钟
mm00-59分钟,两位数
s0-59秒
ss00-59秒 两位数
S0-9毫秒,一位数
SS00-99毫秒,两位数
SSS000-999毫秒,三位数
Z-05:00UTC 的偏移量
ZZ-0500UTC
AAM PM上午 下午 大写
aam pm上午 下午 小写
Do1st... 31st带序数词的月份里的一天

Refer

  • dayjs string-format
Last Updated:
Contributors: rosendo
Prev
date-format
Next
encrypt