modDate()

Modifies a Date object with either offsets or specific times.

This function is valid in v2.19.0 to v2.23.0. This function has been downloaded 10 times.

Parameters

{Date} date
The date to be modified.
{Object} objOptions
The object which specifies how to modify date. The properties will be read and used to modify date (or a copy of date if objOptions is true-ish). For example to offset the year by 2 years into the future you can specify { year: 2 }. To actually set a specific unit of time you can prefix the name of the property with $. For example if this is { $day: 3, $month: 6 } then the month will be set to July (because the month property of a Date object is zero-based) and the day of the month will be set to 3. Valid properties are year (or fullYear), month, day (or date), hour, minute (or min), second (or sec), or millisecond (or ms). You can also use the plural form of those property names. Another set of properties is dow or dow0 (Sunday to Saturday), dow1 (Monday to Sunday), dow2 (Tuesday to Monday), dow3 (Wednesday to Tuesday), dow4 (Thursday to Wednesday), dow5 (Friday to Thursday) and dow6 (Saturday to Friday), all of which allow for setting the day of the week. Additionally you can prefix those names with a $ to actually set the value instead of simply offsetting those values.

Returns

{Date}
If objOptions.clone is true-ish then a copy of date will be modified and returned. Otherwise the same date that was passed will be modified and returned.