outtaspace Posted May 8, 2012 Share Posted May 8, 2012 I have this code to format my integer into hours, mins, secs.. but i want it to do days, hours, mins, secs..I cant work out how to change this to include daysinteger remaining = 180000; integer secs = remaining % 60; integer mins = ((remaining - secs) % 3600) / 60; integer hours = (remaining - mins - secs) / 3600; Link to comment Share on other sites More sharing options...
Kaluura Boa Posted May 8, 2012 Share Posted May 8, 2012 EDIT: Altho my first snippet was correct, I prefer Dora's symetrical beauty in her code. I just added what she forgot. The modulus operator allows you to simplify your calculations a bit. integer secs = remaining % 60; integer mins = (remaining / 60) % 60;integer hours = ((remaining / 3600) % 3600) % 24;integer days = remaining / 86400; 2 days, 2 hours if my calculator is correct... That's all. 1 Link to comment Share on other sites More sharing options...
Dora Gustafson Posted May 8, 2012 Share Posted May 8, 2012 Try this: integer secs = remaining%60; integer mins = (remaining/60)%60; integer hours = (remaining/3600)%24; integer days = remaining/86400; Error in hours corrected 1 Link to comment Share on other sites More sharing options...
outtaspace Posted May 8, 2012 Author Share Posted May 8, 2012 thank you both very much for your help Link to comment Share on other sites More sharing options...
Recommended Posts
Please take a moment to consider if this thread is worth bumping.
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now