# How do I convert unix into days, hours, minutes and secounds?

• 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

• ## Try Construct 3

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• 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.

• 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

• Thank you so much. I understand now ^^

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)