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

setDay

import { setDay } from "https://esm.sh/v135/date-fns@3.6.0/index.d.mts";
@example
// Set week day to Sunday, with the default weekStartsOn of Sunday:
const result = setDay(new Date(2014, 8, 1), 0)
//=> Sun Aug 31 2014 00:00:00
@example
// Set week day to Sunday, with a weekStartsOn of Monday:
const result = setDay(new Date(2014, 8, 1), 0, { weekStartsOn: 1 })
//=> Sun Sep 07 2014 00:00:00
function setDay<DateType extends Date>(
date: DateType | number | string,
day: number,
options?: SetDayOptions,
): DateType;
§
setDay<DateType extends Date>(date: DateType | number | string, day: number, options?: SetDayOptions): DateType
[src]

§Type Parameters

§
DateType extends Date
[src]

§Parameters

§
date: DateType | number | string
[src]
  • The date to be changed
§
day: number
[src]
  • The day of the week of the new date
§
options?: SetDayOptions optional
[src]
  • An object with options.

§Return Type

§
DateType
[src]

The new date with the day of the week set