Date.diff
Date.diff
Function
Returns the difference between two dates, converted in the specified units.
Syntax
date_value.diff(other, unit)
Parameters
| Parameters | Type | Required | Default value | Description |
|---|---|---|---|---|
| other | Date/String/Number | Yes | None | Another date. |
| unit | String | No | millis | Difference unit. |
Return value
| Type | Description |
|---|---|
| Int | The difference between the current date and other. |
Code Example
start = date('2026-01-01 00:00:00') end = start.add(2, 'days') result = end.diff(start, 'days') // Output: 2 print result
Notes
- Supported units: millis, seconds, minutes, hours, days, weeks.