Const
Object containing time units to add
Date to add to (defaults to current date)
New date with added time units
If any time unit is negative
DateUtils.add({ days: 7, hours: 2 }); // Add 7 days and 2 hours to now
DateUtils.add({ months: 1 }, new Date('2023-01-15')); // Add 1 month to specific date
Internal helper for modifying a date by adding or subtracting time units
Object containing time units
Date to modify
1 for addition, -1 for subtraction
New date with modified time units
Converts various date formats to a Date object
Date to convert (Date, number, or string)
Date object
Error if date string is invalid
Returns the first day of the month
Date to get first day of month for (defaults to current date)
Date set to first day of month
Returns the first day of the quarter
Date to get first day of quarter for (defaults to current date)
Date set to first day of quarter
Returns the first day of the week (Sunday)
Date to get first day of week for (defaults to current date)
Date set to first day of week
Returns the first day of the year
Date to get first day of year for (defaults to current date)
Date set to first day of year
Returns the end of the day (23:59:59.999)
Optional
date: DateArgDate to get end of day for (defaults to current date)
Date set to end of day
Returns the last day of the month
Date to get last day of month for (defaults to current date)
Date set to last day of month
Returns the last day of the quarter
Date to get last day of quarter for (defaults to current date)
Date set to last day of quarter
Returns the last day of the week (Saturday)
Date to get last day of week for (defaults to current date)
Date set to last day of week
Returns the last day of the year
Date to get last day of year for (defaults to current date)
Date set to last day of year
Returns the quarter (1-4) of the year
Date to get quarter for (defaults to current date)
Quarter number
Returns the start of the day (00:00:00.000)
Optional
date: DateArgDate to get start of day for (defaults to current date)
Date set to start of day
Returns the week number of the year (1-53)
Date to get week number for (defaults to current date)
Week number
Checks if a date is in the past
Date to check
True if date is in the past
Checks if a date is today
Date to check
True if date is today
Checks if a date is tomorrow
Date to check
True if date is tomorrow
Checks if a date is valid
Date to check
True if date is valid
Checks if a date falls on a weekday
Date to check
True if the date is a weekday
Checks if a date falls on a weekend
Date to check
True if the date is a weekend
Checks if a date is yesterday
Date to check
True if date is yesterday
Normalizes a date to UTC midnight
Date to normalize
Normalized date or null if invalid
Subtracts specified time units from a date
Object containing time units to subtract
Date to subtract from (defaults to current date)
New date with subtracted time units
Error if any time unit is negative
Validates time unit arguments
Time unit arguments to validate
Error if any time unit is negative
Adds specified time units to a date.