date-utils-2020
date utils 2020, format(date: Date, formatter: string)/toDate(a?: any)...
npm i -S date-utils-2020
# or
yarn add date-utils-2020
Usage
import { formatDate, toDate } from 'date-utils-2020'
const date = toDate('2020-12-04')
console.log(date)
const result = formatDate('2020-12-04', 'yyyy/MM/dd W')
console.log(result)
Methods
Method | Parameters | Description |
---|
formatDate | (date: any, fmt: string, langPackage?: langPackage) | return string |
toDate | (s: any) | return Date or null |
isNumberLike | (n: any) | return Boolean true or false |
isString | (n: any) | return Boolean true or false |
toTwoDigits | (n: number) | return string |
langPackage
Props | Type | Description |
---|
weeks | string[] | Example: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'] , Default: ['日', '一', '二', '三', '四', '五', '六'] |
const langPackage = {
weeks: ['日曜日', '月曜日', '火曜日', '水曜日', '木曜日', '金曜日', '土曜日']
}
formatDate(new Date(), 'yyyy/MM/dd(W) hh:mm:ss', langPackage)