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