I want to get some sort of reward between the game sessions depending on how much time the player has been offline
if the player has been offline for 10 minutes and then enter the game he will recive 1 gold for every second so he will get 600 gold.
You can use unixtime expression. While the game is running, save unixtime in local storage. (say, every few seconds or at the end of each level)
When the game starts, try to read it from local storage.
int((unittime-saved_unixtime)/60000)=number of minutes spent offline
Develop games in your browser. Powerful, performant & highly capable.
Hey Thanks a lot it worked just fine <3