I'm getting a data which contains a certain number.
I need to find how many hours, minutes and seconds it stands for.
for example:
I'm getting the number 248 which means:
00 hours : 04 minutes : 08 seconds
Any ideas would be really apprieciated!
To convert time to a number of hours, multiply the time by 24, which is the number of hours in a day. To convert time to minutes, multiply the time by 1440, which is the number of minutes in a day (24*60).
Determine hours, minutes and seconds like this:
int hours = (int) (time / 3600);
int minutes = ((int) (time / 60)) % 60;
int seconds = time % 60;
Alternatively, you can determine minutes like this once you know the hours:
int minutes = (int) ((time - hours * 3600) / 60));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With