Subtract the specified number of days from the given date.
Subtract the specified number of days from the given date.
// CommonJS var subDays = require('date-fns/subDays')
// ES 2015 import subDays from 'date-fns/subDays'
// ESM import { subDays } from 'date-fns'
subDays(date, amount)
Name | Description |
---|---|
date |
the date to be changed |
amount |
the amount of days to be subtracted. Positive decimals will be rounded using |
Description |
---|
the new date with the days subtracted |
Type | Description |
---|---|
TypeError |
2 arguments required |
// Subtract 10 days from 1 September 2014: const result = subDays(new Date(2014, 8, 1), 10) //=> Fri Aug 22 2014 00:00:00
© 2021 Sasha Koss and Lesha Koss
Licensed under the MIT License.
https://date-fns.org/v2.29.2/docs/subDays