Skip to main content

Date methods

Explore the list of methods in dateUtils library.


This documentation offers an in-depth overview of Actioner's dateUtils methods, categorically presenting their functionalities, parameters, returns, and usage examples, serving as a valuable reference for workflow designers.

List of dateUtils methods

Common helpers

  • add: Adds the specified years, months, weeks, days, hours, minutes and seconds to the given date.

  • closestIndexTo: Returns an index of the closest date from the array comparing to the given date.

  • closestTo: Returns a date from the array closest to the given date.

  • compareAsc: Compares the two dates and return -1, 0 or 1.

  • compareDesc: Compares the two dates reverse chronologically and return -1, 0 or 1.

  • format: Formats the date.

  • formatDistance: Returns the distance between the given dates in words.

  • formatDistanceStrict: Returns the distance between the given dates in words.

  • formatDistanceToNow: Returns the distance between the given date and now in words.

  • formatDistanceToNowStrict: Returns the distance between the given date and now in words.

  • formatDuration: Formats a duration in human-readable format

  • formatISO: Formats the date according to the ISO 8601 standard.

  • formatISO9075: Formats the date according to the ISO 9075 standard.

  • formatISODuration: Formats a duration object according as ISO 8601 duration string

  • formatRFC3339: Formats the date according to the RFC 3339 standard.

  • formatRFC7231: Formats the date according to the RFC 7231 standard.

  • formatRelative: Represents the date in words relative to the given base date.

  • intervalToDuration: Converts interval to duration

  • intlFormat: Formats the date with Intl.DateTimeFormat.

  • isAfter: Is the first date after the second one?

  • isBefore: Is the first date before the second one?

  • isDate: Is the given value a date?

  • isEqual: Are the given dates equal?

  • isExists: Is the given date exists?

  • isFuture: Is the given date in the future?

  • isMatch: validates the date string against given formats

  • isPast: Is the given date in the past?

  • isValid: Is the given date valid?

  • lightFormat: Formats the date.

  • max: Returns the latest of the given dates.

  • min: Returns the earliest of the given dates.

  • parse: Parses the date.

  • parseISO: Parses ISO string.

  • parseJSON: Parses a JSON date string.

  • set: Sets date values to a given date.

  • sub: Subtracts the specified years, months, weeks, days, hours, minutes and seconds from the given date.

  • toDate: Converts the given argument to an instance of Date.

Conversion helpers

  • daysToWeeks: Converts days to weeks.

  • hoursToMilliseconds: Converts hours to milliseconds.

  • hoursToMinutes: Converts hours to minutes.

  • hoursToSeconds: Converts hours to seconds.

  • millisecondsToHours: Converts milliseconds to hours.

  • millisecondsToMinutes: Converts milliseconds to minutes.

  • millisecondsToSeconds: Converts milliseconds to seconds.

  • minutesToHours: Converts minutes to hours.

  • minutesToMilliseconds: Converts minutes to milliseconds.

  • minutesToSeconds: Converts minutes to seconds.

  • monthsToQuarters: Converts number of months to quarters.

  • monthsToYears: Converts number of months to years.

  • quartersToMonths: Converts number of quarters to months.

  • quartersToYears: Converts number of quarters to years.

  • secondsToHours: Converts seconds to hours.

  • secondsToMilliseconds: Converts seconds to milliseconds.

  • secondsToMinutes: Converts seconds to minutes.

  • weeksToDays: Converts weeks to days.

  • yearsToMonths: Converts years to months.

  • yearsToQuarters: Converts years to quarters.

Interval helpers

  • areIntervalsOverlapping: Is the given time interval overlapping with another time interval?

  • clamp: Returns a date bounded by the start and the end of the given interval.

  • eachDayOfInterval: Returns the array of dates within the specified time interval.

  • eachHourOfInterval: Returns the array of hours within the specified time interval.

  • eachMinuteOfInterval: Returns the array of minutes within the specified time interval.

  • eachMonthOfInterval: Returns the array of months within the specified time interval.

  • eachQuarterOfInterval: Returns the array of quarters within the specified time interval.

  • eachWeekOfInterval: Returns the array of weeks within the specified time interval.

  • eachWeekendOfInterval: Lists all the Saturdays and Sundays in the given date interval.

  • eachYearOfInterval: Returns the array of yearly timestamps within the specified time interval.

  • getOverlappingDaysInIntervals: Gets the number of days that overlap in two time intervals.

  • isWithinInterval: Is the given date within the interval?

Timestamp helpers

  • fromUnixTime: Create a date from a Unix timestamp.

  • getTime: Gets the milliseconds timestamp of the given date.

  • getUnixTime: Gets the seconds timestamp of the given date.

  • Millisecond Helpers: addMilliseconds`: Add the specified number of milliseconds to the given date.

  • differenceInMilliseconds: Gets the number of milliseconds between the given dates.

  • getMilliseconds: Gets the milliseconds of the given date.

  • milliseconds: Returns the number of milliseconds in the specified, years, months, weeks, days, hours, minutes and seconds.

  • setMilliseconds: Sets the milliseconds to the given date.

  • subMilliseconds: Subtract the specified number of milliseconds from the given date.

Second Helpers

  • addSeconds: Add the specified number of seconds to the given date.

  • differenceInSeconds: Gets the number of seconds between the given dates.

  • endOfSecond: Returns the end of a second for the given date.

  • getSeconds: Gets the seconds of the given date.

  • isSameSecond: Are the given dates in the same second (and hour and day)?

  • isThisSecond: Is the given date in the same second as the current date?

  • setSeconds: Sets the seconds to the given date.

  • startOfSecond: Returns the start of a second for the given date.

  • subSeconds: Subtract the specified number of seconds from the given date.

Minute helpers

  • addMinutes: Add the specified number of minutes to the given date.

  • differenceInMinutes: Gets the number of minutes between the given dates.

  • endOfMinute: Returns the end of a minute for the given date.

  • getMinutes: Gets the minutes of the given date.

  • isSameMinute: Are the given dates in the same minute (and hour and day)?

  • isThisMinute: Is the given date in the same minute as the current date?

  • roundToNearestMinutes: Rounds the given date to the nearest minute

  • setMinutes: Sets the minutes to the given date.

  • startOfMinute: Returns the start of a minute for the given date.

  • subMinutes: Subtract the specified number of minutes from the given date.

  • Hour Helpers: addHours`: Add the specified number of hours to the given date.

  • differenceInHours: Gets the number of hours between the given dates.

  • endOfHour: Returns the end of an hour for the given date.

  • getHours: Gets the hours of the given date.

  • isSameHour: Are the given dates in the same hour (and same day)?

  • isThisHour: Is the given date in the same hour as the current date?

  • setHours: Sets the hours to the given date.

  • startOfHour: Returns the start of an hour for the given date.

  • subHours: Subtract the specified number of hours from the given date.

Day helpers

  • addBusinessDays: Add the specified number of business days (mon - fri) to the given date.

  • addDays: Add the specified number of days to the given date.

  • differenceInBusinessDays: Gets the number of business days between the given dates.

  • differenceInCalendarDays: Gets the number of calendar days between the given dates.

  • differenceInDays: Gets the number of full days between the given dates.

  • endOfDay: Returns the end of a day for the given date.

  • endOfToday: Returns the end of today.

  • endOfTomorrow: Returns the end of tomorrow.

  • endOfYesterday: Returns the end of yesterday.

  • getDate: Gets the day of the month of the given date.

  • getDayOfYear: Gets the day of the year of the given date.

  • isSameDay: Are the given dates in the same day (and year and month)?

  • isToday: Is the given date today?

  • isTomorrow: Is the given date tomorrow?

  • isYesterday: Is the given date yesterday?

  • setDate: Sets the day of the month to the given date.

  • setDayOfYear: Sets the day of the year to the given date.

  • startOfDay: Returns the start of a day for the given date.

  • startOfToday: Returns the start of today.

  • startOfTomorrow: Returns the start of tomorrow.

  • startOfYesterday: Returns the start of yesterday.

  • subBusinessDays: Substract the specified number of business days (mon - fri) to the given date.

  • subDays: Subtract the specified number of days from the given date.

  • Weekday Helpers: getDay`: Gets the day of the week of the given date.

  • getISODay: Gets the day of the ISO week of the given date.

  • isFriday: Is the given date Friday?

  • isMonday: Is the given date Monday?

  • isSaturday: Is the given date Saturday?

  • isSunday: Is the given date Sunday?

  • isThursday: Is the given date Thursday?

  • isTuesday: Is the given date Tuesday?

  • isWednesday: Is the given date Wednesday?

  • isWeekend: Does the given date fall on a weekend?

  • nextDay: When is the next day of the week?

  • nextFriday: When is the next Friday?

  • nextMonday: When is the next Monday?

  • nextSaturday: When is the next Saturday?

  • nextSunday: When is the next Sunday?

  • nextThursday: When is the next Thursday?

  • nextTuesday: When is the next Tuesday?

  • nextWednesday: When is the next Wednesday?

  • previousDay: When is the previous day of the week?

  • previousFriday: When is the previous Friday?

  • previousMonday: When is the previous Monday?

  • previousSaturday: When is the previous Saturday?

  • previousSunday: When is the previous Sunday?

  • previousThursday: When is the previous Thursday?

  • previousTuesday: When is the previous Tuesday?

  • previousWednesday: When is the previous Wednesday?

  • setDay: Sets the day of the week to the given date.

  • setISODay: Sets the day of the ISO week to the given date.

Week helpers

  • addWeeks: Add the specified number of weeks to the given date.

  • differenceInCalendarWeeks: Gets the number of calendar weeks between the given dates.

  • differenceInWeeks: Gets the number of full weeks between the given dates.

  • endOfWeek: Returns the end of a week for the given date.

  • getWeek: Gets the local week index of the given date.

  • getWeekOfMonth: Gets the week of the month of the given date.

  • getWeeksInMonth: Gets the number of calendar weeks a month spans.

  • isSameWeek: Are the given dates in the same week (and month and year)?

  • isThisWeek: Is the given date in the same week as the current date?

  • lastDayOfWeek: Returns the last day of a week for the given date.

  • setWeek: Sets the local week to the given date.

  • startOfWeek: Returns the start of a week for the given date.

  • subWeeks: Subtract the specified number of weeks from the given date.

ISO week helpers

  • differenceInCalendarISOWeeks: Gets the number of calendar ISO weeks between the given dates.

  • endOfISOWeek: Returns the end of an ISO week for the given date.

  • getISOWeek: Gets the ISO week of the given date.

  • isSameISOWeek: Are the given dates in the same ISO week (and year)?

  • isThisISOWeek: Is the given date in the same ISO week as the current date?

  • lastDayOfISOWeek: Returns the last day of an ISO week for the given date.

  • setISOWeek: Sets the ISO week to the given date.

  • startOfISOWeek: Returns the start of an ISO week for the given date.

Month helpers

  • addMonths: Add the specified number of months to the given date.

  • differenceInCalendarMonths: Gets the number of calendar months between the given dates.

  • differenceInMonths: Gets the number of full months between the given dates.

  • eachWeekendOfMonth: List all the Saturdays and Sundays in the given month.

  • endOfMonth: Returns the end of a month for the given date.

  • getDaysInMonth: Gets the number of days in a month of the given date.

  • getMonth: Gets the month of the given date.

  • isFirstDayOfMonth: Is the given date the first day of a month?

  • isLastDayOfMonth: Is the given date the last day of a month?

  • isSameMonth: Are the given dates in the same month (and year)?

  • isThisMonth: Is the given date in the same month as the current date?

  • lastDayOfMonth: Returns the last day of a month for the given date.

  • setMonth: Sets the month to the given date.

  • startOfMonth: Returns the start of a month for the given date.

  • subMonths: Subtract the specified number of months from the given date.

Quarter helpers

  • addQuarters: Add the specified number of year quarters to the given date.

  • differenceInCalendarQuarters: Gets the number of calendar quarters between the given dates.

  • differenceInQuarters: Gets the number of quarters between the given dates.

  • endOfQuarter: Returns the end of a year quarter for the given date.

  • getQuarter: Gets the year quarter of the given date.

  • isSameQuarter: Are the given dates in the same quarter (and year)?

  • isThisQuarter: Is the given date in the same quarter as the current date?

  • lastDayOfQuarter: Returns the last day of a year quarter for the given date.

  • setQuarter: Sets the year quarter to the given date.

  • startOfQuarter: Returns the start of a year quarter for the given date.

  • subQuarters: Subtract the specified number of year quarters from the given date.

Year helpers

  • addYears: Add the specified number of years to the given date.

  • differenceInCalendarYears: Gets the number of calendar years between the given dates.

  • differenceInYears: Gets the number of full years between the given dates.

  • eachWeekendOfYear: List all the Saturdays and Sundays in the year.

  • endOfYear: Returns the end of a year for the given date.

  • getDaysInYear: Gets the number of days in a year of the given date.

  • getYear: Gets the year of the given date.

  • isLeapYear: Is the given date in the leap year?

  • isSameYear: Are the given dates in the same year?

  • isThisYear: Is the given date in the same year as the current date?

  • lastDayOfYear: Returns the last day of a year for the given date.

  • setYear: Sets the year to the given date.

  • startOfYear: Returns the start of a year for the given date.

  • subYears: Subtract the specified number of years from the given date.

ISO week-numbering year helpers

  • addISOWeekYears: Add the specified number of ISO week-numbering years to the given date.

  • differenceInCalendarISOWeekYears: Gets the number of calendar ISO week-numbering years between the given dates.

  • differenceInISOWeekYears: Gets the number of full ISO week-numbering years between the given dates.

  • endOfISOWeekYear: Returns the end of an ISO week-numbering year for the given date.

  • getISOWeekYear: Gets the ISO week-numbering year of the given date.

  • getISOWeeksInYear: Gets the number of weeks in an ISO week-numbering year of the given date.

  • isSameISOWeekYear: Are the given dates in the same ISO week-numbering year?

  • lastDayOfISOWeekYear: Returns the last day of an ISO week-numbering year for the given date.

  • setISOWeekYear: Sets the ISO week-numbering year to the given date.

  • startOfISOWeekYear: Returns the start of an ISO week-numbering year for the given date.

  • subISOWeekYears: Subtract the specified number of ISO week-numbering years from the given date.

Decade helpers

  • endOfDecade: Returns the end of a decade for the given date.

  • getDecade: Gets the decade of the given date.

  • lastDayOfDecade: Returns the last day of a decade for the given date.

  • startOfDecade: Returns the start of a decade for the given date.

Week-numbering year helpers

  • getWeekYear: Gets the local week-numbering year of the given date.

  • setWeekYear: Sets the local week-numbering year to the given date.

  • startOfWeekYear: Returns the start of a local week-numbering year for the given date.