How do I get the time in seconds

Get help using Construct 2

Post » Thu Apr 13, 2017 2:08 am

Hello, i am trying to create a "System" in my game that captures the player idle time (time away), i already tried to use "Time Away L" plugin (using Time Away L it works really fine on the preview, but when the game its exported (android), it doesnt work). So i am trying something different, get the current date in seconds and do the calculation to get the "Idle Time", does anyone have any idea how i do this?
B
13
S
1
Posts: 58
Reputation: 701

Post » Thu Apr 13, 2017 3:55 am

Browser.ExecJS("Date.now()") will give you the system's Unix time in ms.

To get seconds, divide by 1000 and round. You should save this value to local storage every x seconds, and compare the current Unix time with the saved time upon resuming the game.
Mistakes were made.
B
52
S
26
G
110
Posts: 1,620
Reputation: 62,161

Post » Thu Apr 13, 2017 8:16 pm

oosyrag wrote:Browser.ExecJS("Date.now()") will give you the system's Unix time in ms.

To get seconds, divide by 1000 and round. You should save this value to local storage every x seconds, and compare the current Unix time with the saved time upon resuming the game.



Thanks
B
13
S
1
Posts: 58
Reputation: 701


Return to How do I....?

Who is online

Users browsing this forum: Exabot [Bot], Kin, ratboy3, tinhofiel and 37 guests