1.1.0 • Published 3 years ago

dtil v1.1.0

Weekly downloads
19
License
MIT
Repository
github
Last release
3 years ago

Dtil

npm package simple date util

npm.io npm.io

Installing

Using npm

$ npm install dtil

Using yarn

$ yarn add dtil

Example

Import

You can import function. Imported function return Dtil class object.

ES5

const dtil = require('dtil');

const aDtil = dtil('2020-08-28'); // Date string
const bDtil = dtil(new Date('2020-08-28')); // Date object
const cDtil = dtil(new Date('2020-08-28').getTime()); // number

ES6

import dtil from 'dtil';

const aDtil = dtil('2020-08-28'); // Date string
const bDtil = dtil(new Date('2020-08-28')); // Date object
const cDtil = dtil(new Date('2020-08-28').getTime()); // number

Format

chardescription
yyyy / YYYYyear
MMtwo-digit month
Mmonth
dd / DDtwo-digit date
d / Ddate
HHtwo-digit hour(24)
Hhour(24)
hhtwo-digit hour(12)
hhour(12)
mmtwo-digit minute
mminute
SS / sstwo-digit second
S / ssecond

Usage

const dtil = require('dtil');

const date = dtil('2020-08-28');
console.log(date.format('yyyy/MM/dd')); // result: '2020/08/28'

Method

methodreturn typedescription
formatstringformat date string
isSameDatebooleancheck date and param is same date
isAfterbooleancheck date is after param
isAfterNowbooleancheck date is after now
isBeforebooleancheck date is before param
isBeforeNowbooleancheck date is before now
1.1.0

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago