Converting seconds to HH:MM:SS
#3

Here's a stock function I whipped up quickly to convert it for you:

pawn Код:
/*Usage: The seconds parameter should be the amount of seconds you want to convert and
the rest of the parameters should be variables to store the integer value for each of the
time values*/

stock formatSeconds(seconds, &hours_left, &minutes_left, &seconds_left)
{
    hours_left = seconds/60/60;
    minutes_left = (seconds - hours_left*60*60)/60;
    seconds_left = (seconds - hours_left*60*60 - minutes_left*60);
    return 1;
}
Usage example:

pawn Код:
new
    hours,
    minutes,
    seconds;
   
formatSeconds(5000, hours, minutes, seconds);
   
printf("Hours: %d, Minutes: %d, Seconds: %d in 5000 seconds", hours, minutes, seconds);
Hope that's what you were looking for!
Reply


Messages In This Thread
Converting seconds to HH:MM:SS - by Hobod - 10.05.2011, 15:31
Re: Converting seconds to HH:MM:SS - by Zh3r0 - 10.05.2011, 15:37
Re: Converting seconds to HH:MM:SS - by JaTochNietDan - 10.05.2011, 15:51
Re: Converting seconds to HH:MM:SS - by Hobod - 10.05.2011, 17:15
Re: Converting seconds to HH:MM:SS - by Zh3r0 - 10.05.2011, 17:23
Re: Converting seconds to HH:MM:SS - by Hobod - 10.05.2011, 17:45
Re: Converting seconds to HH:MM:SS - by Calgon - 10.05.2011, 17:46

Forum Jump:


Users browsing this thread: 2 Guest(s)