Server Time
Yandex Games SDK allows you to retrieve server-synchronized time. The ysdk.serverTime()
method is resistant to player manipulation and useful for determining precise time that is not affected by client settings (time zones, dates, and times).
Based on this, you can add activities and rewards that require a trusted time source: daily or weekly bonuses, seasons, quests, etc.
ysdk.serverTime()
The ysdk.serverTime()
method should be called whenever you need to fetch the current time. It returns a timestamp
similar to the Date.now()
method.
Example
Using await
Without using await
const ysdk = await YaGames.init();
// Returns the time in milliseconds synchronized with the server.
ysdk.serverTime(); // For example, 1720613073778.
// Call it again after some time.
ysdk.serverTime(); // For example, 1720613132635.
YaGames.init().then(ysdk => {
// Returns the time in milliseconds synchronized with the server.
ysdk.serverTime(); // For example, 1720613073778.
// Call it again after some time.
ysdk.serverTime(); // For example, 1720613132635.
});