datetime.diff()
Determines the number of given date parts between two different dates
With Lucee 6, the order of the arguments for this .diff() member function was changed to match ACF
datetime.diff( datePart=string, date1=datetime )
Returns: Number
| Argument | Description |
|---|---|
|
datePart
string,
required
|
edit
String that specifies the units in which to count:
|
|
date1
datetime,
required
|
edit
date time object to compare |
Examples
edit date = createDateTime(1997,04,11);
echo( date.Diff("d", "1997-04-25") & "<br>"); // 1
dateOne = createDate(1997,04,11);
echo( dateOne.Diff("d", "1997-04-11") & "<br>"); // 0
datetime = createDateTime(1992,12,11,01,00,00);
echo( datetime.Diff("h", "1992-12-11 00:00:00") & "<br>"); // -1