day = sec / hr = sec / 60 / 60; min = (sec - horas * 3600) / 60; seg = sec % 60; 

Tell me how to connect the days?

  • @extazys, are you a little perverted over UNIX TimeStamp? - Salivan


2 answers 2

1 day = 24 hours
1 hour = 60 minutes, i.e. 1 day = 24 * 60 minutes
1 minute = 60 seconds, i.e. 1 day = 24 * 60 * 60 seconds,

those. in X seconds X / ( 24 * 60 * 60 ) days

usually you need to set the time in a specific format like dd: hh: mm: ss, and not just the number of minutes or seconds

Is logical Then we calculate the remains:

D = 24 * 60 * 60
H = 60 * 60
M = 60

XD = X / D days
XH = ( X - XD * D ) / H hours
XM = ( X - XD * D - XH * H ) / M minutes
XS = ( X - XD * D - XH * H - XM * M ) seconds

    Given 100 seconds, find: minutes, hours, days. Decision:

     1min = 60 sec => 100 sec = 100/60 1 hour = 60 min = 60*60 sec => 100/60/60 1 day = 24 hour = 24*60 min = 24*60*60 sec = 100/24/60/60 

    not?

    • one
      not. And who will count the remains? - gecube
    • @gecube is required? - lampa
    • For sure! Because usually you need to set the time in a format like dd: hh: mm: ss, and not just the number of minutes or seconds ... - gecube
    • one
      @gecube and what if I do in this format, but it turns out that it was not necessary? I think it should be unfinished, than to redo. Especially in the TK nothing about the translation in what format does not say. - lampa