dtil
v1.1.0
Published
simple date util
Downloads
38
Maintainers
Readme
Dtil
npm package simple date util
Installing
Using npm
$ npm install dtilUsing yarn
$ yarn add dtilExample
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()); // numberES6
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()); // numberFormat
|char|description| |---|---| |yyyy / YYYY|year| |MM|two-digit month | |M|month| |dd / DD|two-digit date| |d / D|date| |HH|two-digit hour(24)| |H|hour(24)| |hh|two-digit hour(12)| |h|hour(12)| |mm|two-digit minute| |m|minute| |SS / ss|two-digit second| |S / s|second|
Usage
const dtil = require('dtil');
const date = dtil('2020-08-28');
console.log(date.format('yyyy/MM/dd')); // result: '2020/08/28'Method
|method|return type|description| |---|---|---| |format|string|format date string| |isSameDate|boolean|check date and param is same date| |isAfter|boolean|check date is after param| |isAfterNow|boolean|check date is after now| |isBefore|boolean|check date is before param| |isBeforeNow|boolean|check date is before now|
