@jswork/simple-date-format
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

simple-date-format

A simple date format.

version license size download

installation

npm install @jswork/simple-date-format

usage

import sdf from '@jswork/simple-date-format';

// get current datetime:
const res1 = sdf('YYYY-MM-DD HH:mm:ss');
// 2020-01-01 12:12:12

// use format hooks
const res2 = sdf('date');
// 2020-01-01

format hooks

const FORMAT_HOOKS = {
  date: 'YYYY-MM-DD',
  datetime: 'YYYY-MM-DD HH:mm:ss',
  time: 'HH:mm:ss',
  month: 'YYYY-MM',
  dbdt: 'YYYYMMDD_HHmmss',
  fullday: 'YYYY/YYYY-MM/YYYY-MM-DD'
};

formats

format Output Description
YY 18 两位数的年份
YYYY 2018 四位数的年份
M 1-12 月份,从 1 开始
MM 01-12 月份,两位数
D 1-31 月份里的一天
DD 01-31 月份里的一天,两位数

license

Code released under the MIT license.

Package Sidebar

Install

npm i @jswork/simple-date-format

Homepage

js.work

Weekly Downloads

57

Version

1.0.5

License

MIT

Unpacked Size

8.16 kB

Total Files

6

Last publish

Collaborators

  • afeiship