date-fns-duration

1.0.4 • Public • Published

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

 
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");
 

Package Sidebar

Install

npm i date-fns-duration

Weekly Downloads

2,306

Version

1.0.4

License

MIT

Unpacked Size

2.22 kB

Total Files

3

Last publish

Collaborators

  • pke