Chrono - Reliable Server Time



Chrono helps to easily get a server based timestamp when you don’t want to trust local device time for whatever reason but also don’t want to host your own server.


1 Like


Chrono returns a timestamp like this: 1599744156.8765. I need to trigger an event once per day in my game. How can I convert the time stamp to days? Through aggressive googling I found this possible solution:

local days = chrono.get_time()/86400

Since I’ve never used NTP for something like this before, I wanted to sense check this with the ever-helpful Defold community.



If you’re not treating it as a date, I guess you’ll be fine, since you’re not really accounting for leap years.

1599744156/(60*60*24*365) = 50,7275544418

0,7275544418 * 365 = 265,557371257

Epoch is 1970/1/1, and 50 years later, it’s 2020.
IN the year of 2020, it’s actually day 254, so that’s why you can’t trust your calculation as the proper day.

But, if you just compare two times, then yes 86400 is the number of seconds in a day.



Thanks so much. This is the clearest explanation I’ve found so far. You beat Google!