Skip to content

Global Helpers

timeUntilInWords()

timeUntilInWords() — returns string

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

Returns a string describing the approximate time difference between the current date and the date passed in.

NameTypeRequiredDefaultDescription
toTimedateyes—Date to compare to.
includeSecondsbooleannofalseWhether or not to include the number of seconds in the returned string.
fromTimedateno[runtime expression]Date to compare from.
// 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"