https://github.com/pke/date-fns-duration
Complementary package for date-fns to add/subtract ISO 8601 durations to/from dates.
https://github.com/pke/date-fns-duration
Last synced: 6 months ago
JSON representation
Complementary package for date-fns to add/subtract ISO 8601 durations to/from dates.
- Host: GitHub
- URL: https://github.com/pke/date-fns-duration
- Owner: pke
- Created: 2019-12-29T21:22:26.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-07-04T07:16:44.000Z (over 2 years ago)
- Last Synced: 2025-03-28T20:12:17.677Z (6 months ago)
- Language: JavaScript
- Homepage:
- Size: 504 KB
- Stars: 12
- Watchers: 3
- Forks: 3
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# data-fns-duration
Complementary package for `date-fns` to add/subtract ISO 8601 durations to/from
dates.## Installation
Install it alongside `date-fns`
`npm i -S date-fns-duration`
## API
```js
import addDuration from 'date-fns-duration';
// addDuration(date, duration);
// Add duration
const two_hours_from_now = addDuration(Date.now(), "PT2H");// Subtract duration
const month_before = addDuration("2018-10-02T10:00", "-P1M");```