Skip to main content
Very Popular
Latest
function default
import { default } from "https://deno.land/x/date_fns@v2.22.1/subYears/index.ts";

Examples

// Subtract 5 years from 1 September 2014: const result = subYears(new Date(2014, 8, 1), 5) //=> Tue Sep 01 2009 00:00:00

Parameters

dirtyDate: Date | number
  • the date to be changed
dirtyAmount: number
  • the amount of years to be subtracted. Positive decimals will be rounded using Math.floor, decimals less than zero will be rounded using Math.ceil.

Returns

the new date with the years subtracted