I compare two unix numbers to each other, and need to convert difference into Days, Hours, Minutes and secounds. How do I do this?
- Thanks in advance
unixtime/1000 = seconds
unixtime/60000 = minutes
unixtime/3600000 = hours
unixtime/86400000 = days
You can use the % (modulo) operator to get the remainder after dividing.
Also, check out this demo how to display time in hh:mm:ss.ms format
howtoconstructdemos.com/simple-stopwatch
oosyrag. I don't understand how to use %? I can't seem to figure out how to use it, so that every time secounds hit 60, the minutes add up with 1.
Develop games in your browser. Powerful, performant & highly capable.
You need to work backwards. Modulo gives you the remainder after dividing. So imagine 132 total seconds. First you need to divide by 60 and round down to get the number of minutes, which is 2. The remainder after that is 12, which would be your seconds.
floor(132/60)=2
132%60=12
dropbox.com/s/9reee8ph9n72qsu/unixtime.c3p
Thank you so much. I understand now ^^