Global Helpers
distanceOfTimeInWords()
Signature
Section titled “Signature”distanceOfTimeInWords() — returns string
Available in: controller, model, migrator, migration, tabledefinition
Category: Date Functions
Description
Section titled “Description”Pass in two dates to this method, and it will return a string describing the difference between them.
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
fromTime | date | yes | — | Date to compare from. |
toTime | date | yes | — | Date to compare to. |
includeSeconds | boolean | no | false | Whether or not to include the number of seconds in the returned string. |
Examples
Section titled “Examples”// Controller code.
rightNow = Now();
aWhileAgo = DateAdd("d", -30, rightNow);
// View code.
<!--- Will output: about 1 month --->
#distanceOfTimeInWords(aWhileAgo, rightNow)#