Global Helpers
timeUntilInWords()
Signature
Section titled “Signature”timeUntilInWords() — returns string
Available in: controller, model, test, migrator, migration, tabledefinition
Category: Date Functions
Description
Section titled “Description”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.
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
toTime | date | yes | — | Date to compare to. |
includeSeconds | boolean | no | false | Whether or not to include the number of seconds in the returned string. |
fromTime | date | no | [runtime expression] | Date to compare from. |
Examples
Section titled “Examples”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)