Global Helpers
timeUntilInWords()
Signature
Section titled “Signature”timeUntilInWords() — returns string
Available in: controller, model, mapper, migrator, migration, tabledefinition
Category: Date Functions
Description
Section titled “Description”Returns a string describing the approximate time difference between the current date and the date passed in.
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. Show approximate time until a future date
nextYear = DateAdd("yyyy", 1, Now());
writeOutput(timeUntilInWords(nextYear));
// -> "about 1 year"
// 2. Include seconds for a near-future time
soonish = DateAdd("s", 8, Now());
writeOutput(timeUntilInWords(toTime=soonish, includeSeconds=true));
// -> "less than 10 seconds"
// 3. Compare two explicit dates (custom fromTime)
launchDate = CreateDate(2025, 6, 1);
deadline = CreateDate(2025, 9, 15);
writeOutput(timeUntilInWords(toTime=deadline, fromTime=launchDate));
// -> "about 3 months"