add-subtract-date
Add or subtract a specified time in a date object.
:cloud: Installation
$ npm i --save add-subtract-date
:clipboard: Example
const addSubtractDate = require("add-subtract-date");
var d = new Date(1989, 11, 20);
console.log(addSubtractDate.add(d, 2, "days"));
console.log(addSubtractDate.subtract(d, 1, "day"));
console.log(addSubtractDate.subtract(d, 1, "year"));
console.log(addSubtractDate.add(d, 10, "hours"));
console.log(addSubtractDate.add(d, 42, "minutes"));
console.log(addSubtractDate.add(d, 7, "seconds"));
console.log(addSubtractDate.add(d, 142, "milliseconds"));
console.log(addSubtractDate.subtract(d, 1, "week"));
:memo: Documentation
gen()
The module exports an object containing two methods: add
(goes in the future) and subtract
(goes in the past).
They require the following arguments:
-
d
(Date): The date object.
-
count
(Number): How many years/months/etc to add/subtract.
-
what
(String): What to add/subtract. Supported values are:
years
year
months
month
weeks
week
days
day
hours
hour
minutes
minute
seconds
second
milliseconds
millisecond
:yum: How to contribute
Have an idea? Found a bug? See how to contribute.
:moneybag: Donations
Another way to support the development of my open-source modules is
to set up a recurring donation, via Patreon. :rocket:
PayPal donations are appreciated too! Each dollar helps.
Thanks! :heart:
:dizzy: Where is this library used?
If you are using this library in one of your projects, add it in this list. :sparkles:
daty
—A tiny library to manage date objects.github-calendar
—Embed your GitHub contributions calendar anywhere.
:scroll: License
MIT © Ionică Bizău