Skip to main content

Dates and durations

Get and change dates, calculate differences, and convert durations and dates to and from text.

Current date/time​

Returns the current date and time.

Outputs

NameTypeDetails
NowDate and timeThe current moment.

Text to date​

Reads a date from a text, optionally with a format. Times without a timezone are read in the bot's timezone.

Inputs

NameTypeRequiredDetails
TextTextYesText representation of the date.
FormatTextNoOptional format pattern.

Outputs

NameTypeDetails
DateDate and timeThe date, or empty if the text could not be read as a date. May be empty.

Add to date​

Adds a duration to a date and returns the new date.

Inputs

NameTypeRequiredDetails
DateDate and timeYesThe starting date.
DurationDurationYesHow much to add.

Outputs

NameTypeDetails
ResultDate and timeThe resulting date.

Subtract from date​

Subtracts a duration from a date and returns the new date.

Inputs

NameTypeRequiredDetails
DateDate and timeYesThe starting date.
DurationDurationYesHow much to subtract.

Outputs

NameTypeDetails
ResultDate and timeThe resulting date.

Date difference​

Returns the duration between two dates (a - b).

Inputs

NameTypeRequiredDetails
ADate and timeYesFirst date.
BDate and timeYesSecond date.

Outputs

NameTypeDetails
DurationDurationThe duration between the dates.

Format date​

Formats a date as a text using a format pattern, in the bot's timezone.

Inputs

NameTypeRequiredDetails
DateDate and timeYesThe date to format.
FormatTextYesFormat pattern (e.g. YYYY-MM-DD).
LocaleTextNoOptional locale (e.g. de-DE).

Outputs

NameTypeDetails
ResultTextThe formatted text.

Extract year​

Returns the year part of a date, in the bot's timezone.

Inputs

NameTypeRequiredDetails
DateDate and timeYesThe date to inspect.

Outputs

NameTypeDetails
YearWhole numberThe year (e.g. 2026).

Extract month​

Returns the month part of a date (1-12), in the bot's timezone.

Inputs

NameTypeRequiredDetails
DateDate and timeYesThe date to inspect.

Outputs

NameTypeDetails
MonthWhole numberMonth number 1-12.

Extract day​

Returns the day-of-month part of a date (1-31), in the bot's timezone.

Inputs

NameTypeRequiredDetails
DateDate and timeYesThe date to inspect.

Outputs

NameTypeDetails
DayWhole numberDay-of-month 1-31.

Extract hour​

Returns the hour-of-day part of a date (0-23), in the bot's timezone.

Inputs

NameTypeRequiredDetails
DateDate and timeYesThe date to inspect.

Outputs

NameTypeDetails
HourWhole numberHour 0-23.

Extract weekday​

Returns the day-of-week index (0 = Sunday, 6 = Saturday), in the bot's timezone.

Inputs

NameTypeRequiredDetails
DateDate and timeYesThe date to inspect.

Outputs

NameTypeDetails
WeekdayWhole numberDay-of-week index (0-6).

Duration from ms​

Builds a duration from a number of milliseconds.

Inputs

NameTypeRequiredDetails
MillisecondsWhole numberYesNumber of milliseconds. Minimum: 0.

Outputs

NameTypeDetails
DurationDurationThe resulting duration.

Duration to ms​

Converts a duration to its total number of milliseconds.

Inputs

NameTypeRequiredDetails
DurationDurationYesThe duration to convert.

Outputs

NameTypeDetails
MillisecondsWhole numberTotal milliseconds.

Duration from parts​

Builds a duration from days, hours, minutes, and seconds.

Inputs

NameTypeRequiredDetails
DaysWhole numberNoNumber of days. Default: 0.
HoursWhole numberNoNumber of hours. Default: 0.
MinutesWhole numberNoNumber of minutes. Default: 0.
SecondsWhole numberNoNumber of seconds. Default: 0.

Outputs

NameTypeDetails
DurationDurationThe resulting duration.

Text to duration​

Reads a human-readable duration such as "10m", "2h30m", "3d" or "1w2d" from text. Units are required, a bare number is not accepted. Returns the fallback (or fails) when the text cannot be read as a duration.

Inputs

NameTypeRequiredDetails
TextTextYesThe duration text, e.g. "10m", "2h30m", "3d", "1w2d", "90s".
FallbackDurationNoReturned instead of failing when the text cannot be read as a duration. Leave empty to raise a catchable error on invalid input.

Outputs

NameTypeDetails
DurationDurationThe duration, or the fallback when the text cannot be read. May be empty.

Format duration​

Formats a duration as human-readable text.

Inputs

NameTypeRequiredDetails
DurationDurationYesThe duration to format.
StyleDuration styleYesHow to render the duration: compact ("2h 30m"), long ("2 hours 30 minutes") or the largest unit only ("3 hours"). Default: Compact.

Outputs

NameTypeDetails
TextTextThe formatted duration text.

Text to date (everyday wording)​

Reads everyday relative and absolute date and time wording into a date. Relative: "in 3 days"/"in 5 minuten" (English and German duration words, seconds/minutes/hours/days/weeks, month/year approximate), "tomorrow 8pm", "today 15:00", "next monday" (weekday names in English and German). Absolute: ISO-8601, "2024-03-05", "05.03.2024", "15:00". Returns the fallback (or fails) when the text cannot be read as a date.

Inputs

NameTypeRequiredDetails
TextTextYesThe date/time text, e.g. "in 3 days", "in 5 minuten", "tomorrow 8pm", "next monday", "2024-03-05", "05.03.2024".
Reference timeDate and timeNoThe "now" used for relative forms like "tomorrow" or "in 3 days". Defaults to the current time.
TimezoneTextNoIANA timezone (e.g. "Europe/Berlin") used to interpret wall-clock times like "tomorrow 8pm". Defaults to the bot's timezone.
FallbackDate and timeNoReturned instead of failing when the text cannot be read as a date. Leave empty to raise a catchable error on invalid input.

Outputs

NameTypeDetails
DateDate and timeThe date and time, or the fallback when the text cannot be read. May be empty.

Time until​

Measures the distance from the reference time to a target date. The milliseconds are negative when the target is in the past.

Inputs

NameTypeRequiredDetails
Target dateDate and timeYesThe date and time to measure to.
Reference timeDate and timeNoThe time to measure from. Defaults to the current time.

Outputs

NameTypeDetails
MillisecondsWhole numberSigned milliseconds from the reference to the target (negative when the target is in the past).
Is in the pastYes/NoTrue when the target is before the reference time.
HumanizedTextA human-readable phrase such as "in 2 hours 30 minutes", "2 days ago" or "now".
Need more help?
Can't find what you're looking for? Our team is happy to help.