Skip to content

Global Helpers

timeAgoInWords()

timeAgoInWords() — returns any

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

Returns a human-friendly string describing the approximate time difference between two dates (defaults to comparing against the current time).

NameTypeRequiredDefaultDescription
fromTimedateyesDate to compare from.
includeSecondsbooleannofalseWhether or not to include the number of seconds in the returned string.
toTimedateno[runtime expression]Date to compare to.
1. Example in a controller (outputs: "3 months")
aWhileAgo = DateAdd("d", -90, Now());
timeAgoInWords(aWhileAgo)

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

3. Comparing two specific dates (Outputs: "5 months")
past = CreateDateTime(2024, 01, 01, 12, 0, 0);
future = CreateDateTime(2024, 06, 01, 12, 0, 0);
timeAgoInWords(fromTime=past, toTime=future)