-
Notifications
You must be signed in to change notification settings - Fork 1
modifyDate
kherP edited this page Jan 2, 2020
·
2 revisions
This utility modifies a date by either adding or subtracting a certain range.
const date = new Date("2019-10-27");
const result = modifyDate(date, 28, "SUBTRACT", "Year");
console.log(result); // "Sun Oct 27 1991 00:00:00 GMT+0800 (Malaysia Time)"
Param | Type | Description |
---|---|---|
from | Date | the starting date |
value | number | the value to be added or subtracted |
type |
ADD | SUBTRACT
|
operation type |
range | moment.DurationInputArg2 | unit to be calculated in, eg, months | seconds | h
|