setWeek

Modified on Tue, 22 Aug 2023

Description

Use this function to set the local week to the given date, saving the weekday number. The "week" parameter allows you to specify the desired week number, and you can also customize the first weekday using the "options" parameter. The function will return the resulting date with the specified week and weekday configuration.

Syntax

setWeek(date, week, options)

Returns

Return ValueDescription
DateReturn the resulting date.

Sample

ExampleResultDescription
setWeek(2023-4-10, 16, {'first_weekday': 0})2023-04-10 (set to week 16 with Monday as the first weekday)Set the date to week 16 with Monday as the first weekday.

To view all the Date functions, click here.

See Also