Skip to content

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].

1
2
3
// 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

1
timeOffset = 829.5

now()

Makes a request to get the Singular server time as UTC timestamp.

1
2
3
// 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

1
timeNow = 1588976118246.5