@splitsecond/update
v1.0.0
Published
Updates an existing datetime string by adding or subtracting some units
Downloads
1
Readme
@splitsecond/update
Updates an existing datetime string by adding or subtracting some units.
splitsecond
is a simple date manipulation library for Node. This library always returns ISO 8601 datetime stamps in UTC.
Installation
npm i -S @splitsecond/update
or
yarn add @splitsecond/update
Usage
update(datetimestamp: string, units: Units): string
const update = require("@splitsecond/update");
// To add, specify the units as positive numbers
update("2020-03-26T20:41:15.791Z", { seconds: 4 });
// '2020-03-26T20:41:19.791Z'
// To subtract, specify them as negative numbers
update("2020-03-26T20:41:15.791Z", { minutes: -3 });
// '2020-03-26T20:38:15.791Z'
Units
{
"milliseconds": 3,
"seconds": 4,
"minutes": -5,
"hours": 1,
"days": 1,
"weeks": 0
}