date-manip
v1.0.1
Published
A modern JavaScript Date utility library delivering modularity, performance, & extras.
Downloads
4,773
Maintainers
Readme
date-manip
Note: A modern JavaScript Date utility library delivering modularity, performance, & extras.
Installation
Load date-manip
via classical <script>
tag
<script src="https://cdn.jsdelivr.net/npm/date-manip/date-manip.umd.min.js"></script>
<script>
// window.dateManip
dateManip.add
dateManip.format
// ...
</script>
<script src="https://cdn.jsdelivr.net/npm/date-manip/date-chain.umd.min.js"></script>
<script>
// window.DateChain
DateChain.add
DateChain.format
// ...
var now = new DateChain(); // DateChain();
now.add
now.format
// ...
</script>
CommonJS style with npm
npm install date-manip --save
// es6
import {
add,
format,
// ...
} from 'date-manip';
// or
import { ... } from 'date-manip/es';
// modularity
import add from 'date-manip/add';
import format from 'date-manip/format';
// date-chain
import moment from 'date-manip/date-chain';
moment('2000-2-29')
.add({
year: 1,
month: 1,
day: 1,
hour: 1,
minute: 1,
second: 1,
millisecond: 1
})
.add(1, 'month')
.startOf('date')
.format('YYYY-MM-DD');
API
- add
- addDays
- addHours
- addMilliseconds
- addMinutes
- addMonths
- addSeconds
- addYears
- clone
- dayOfYear
- daysInMonth
- diff
- endOf
- format
- get
- isAfter
- isBefore
- isBetween
- isLeapYear
- isSame
- isSameOrAfter
- isSameOrBefore
- isValid
- parse
- set
- startOf
- subtract