ServerDate Object¶
Returns the object to request time details from the Singular server. ServerDate()
is required for synchronizing clocks and timers between in the app instance, and the overlay.
Methods¶
The ServerDate object has following methods:
Method | Return type | Brief description |
---|---|---|
getOffset() | number | Returns the time offset between the Singular Server and the local device in [ms] |
now() | number | Returns the Singular server time as UTC timestamp |
getOffset()¶
Makes a request to fetch the time offset between the Singular server and the local device in [ms].
// The code below prints the time offset to the console
var timeOffset = singularApp.ServerDate().getOffset();
console.log("timeOffset =", timeOffset);
Return
number
- time offset as number
timeOffset = 829.5
now()¶
Makes a request to get the Singular server time as UTC timestamp.
// The code below prints the Singular server time to the console
var timeNow = singularApp.ServerDate().now();
console.log("timeNow =", timeNow);
Return
number
- server time as number
timeNow = 1588976118246.5