PFR: Convert elapsed seconds to H:MM:SS 
Author Message
 PFR: Convert elapsed seconds to H:MM:SS

# This fragment takes $s, an elapsed time in seconds,
# and formats it as HH:MM:SS.
sprintf "%d:%02d:%02d",  int($s/3600), int($s/60)%60, $s%60;

# If $s may be negative, can use this expression instead:
sprintf "%s%d:%02d:%02d",  ($s<0?'-':''),  
        int(abs($s)/3600), int(abs($s)/60)%60, abs($s)%60;

Thu, 02 Aug 2001 03:00:00 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Format seconds to hh:mm:ss in Perl

2. procedure to convert sec to HH:MM:SS format

3. Need help with converting hh:mm:ss to just ss.

4. How to get clock ticks or calculate elapsed time less than a second

5. PFR: Convert engineering notation to arbitrary fixed-point format

6. Converting to elapsed time...

7. Convert DD-MM-YYYY to age

8. help in converting time() into dd/mm/yyyy hh:mi format

9. convert a datestring to time (seconds since 1:st Jan of 1970)

10. Problem converting data (second try with more info)

11. Converting a string to time value (seconds since Epoch)

12. convert a date-time to an absolute value (in seconds or so)


Powered by phpBB® Forum Software