Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

setYear

import { setYear } from "https://esm.sh/v135/date-fns@3.6.0/index.d.mts";
@example
// Set year 2013 to 1 September 2014:
const result = setYear(new Date(2014, 8, 1), 2013)
//=> Sun Sep 01 2013 00:00:00
function setYear<DateType extends Date>(date: DateType | number | string, year: number): DateType;
§
setYear<DateType extends Date>(date: DateType | number | string, year: number): DateType
[src]

§Type Parameters

§
DateType extends Date
[src]

§Parameters

§
date: DateType | number | string
[src]
  • The date to be changed
§
year: number
[src]
  • The year of the new date

§Return Type

§
DateType
[src]

The new date with the year set