Skip to content

Global Helpers

timeUntilInWords()

timeUntilInWords() — returns string

Available in: controller, model, test, migrator, migration, tabledefinition Category: Date Functions

Returns a human-readable string describing the approximate time difference between the current date (or another starting point you provide) and a future date. It is the inverse of timeAgoInWords(), focusing on how long until something happens instead of how long ago it occurred. You can optionally include seconds for more precise descriptions.

NameTypeRequiredDefaultDescription
toTimedateyesDate to compare to.
includeSecondsbooleannofalseWhether or not to include the number of seconds in the returned string.
fromTimedateno[runtime expression]Date to compare from.
1. Example in a controller (outputs: "about 1 year")
aLittleAhead = DateAdd("d", 365, Now());
timeUntilInWords(aLittleAhead)

2. Including seconds (outputs: "less than 5 seconds")
timeUntilInWords(DateAdd("s", 3, Now()), includeSeconds=true)

3. Comparing between two specific dates (Outputs: "5 months")
fromDate = CreateDateTime(2024, 01, 01, 12, 0, 0);
toDate = CreateDateTime(2024, 06, 01, 12, 0, 0);
timeUntilInWords(toTime=toDate, fromTime=fromDate)