timeDifference (NotesDateTime - JavaScript™)
Finds the difference in seconds between one date-time value and another.
Defined in
NotesDateTimeSyntax
timeDifference(dt:NotesDateTime) : int
timeDifferenceDouble(dt:NotesDateTime) : double
Parameter | Description |
---|---|
dt |
Any date-time value. |
Return value | Description |
---|---|
int or double |
The date-time value of the object minus the date-time value of the parameter, in seconds. |
Usage
In JavaScript™, both methods return a double-precision number so are effectively the same.Examples
This computed field returns the number of days since the current document was created.var doc:NotesDocument = currentDocument.getDocument();
var created:NotesDateTime = doc.getCreated();
var now:NotesDateTime = session.createDateTime("Today 12");
now.setNow();
var days:int = now.timeDifferenceDouble(created) / 86400; // 86400 seconds in a day
return "This document was created " + Math.floor(days) + " days ago."