Date Extensions
v0.1.0
The Date Extension methods extend the global Date Object´s Prototype.
Usage
Import the extensions part as early as possible to make sure the global Object Prototypes are extended.
Your IDE might offer the typing without importing this init function as they are declared globally.
Date Extensions are using dayjs internally.
import { initDateExtensions } from '@oardi/ts-utils';
initDateExtensions();
add
const date = new Date();
date.add(15, 'minutes');
diff
const startDate = new Date();
const endDate = new Date();
startDate.diff(endDate);
isAfter
const startDate = new Date();
const endDate = new Date();
startDate.isAfter(endDate);
isBefore
const startDate = new Date();
const endDate = new Date();
startDate.isBefore(endDate); Previous: Extensions
← Array ExtensionNext: Extensions
String Extension →