Posted By

zierocode on 01/09/12


Tagged

second convert sec


Versions (?)

Converting second to readable time


 / Published in: PHP
 

This code is applied from http://www.ultramegatech.com/blog/2009/06/snippet-converting-seconds-to-readable-time/

  1. function formatTime($secs) {
  2. $time = '';
  3. foreach (array(3600, 60, 1) as $i => $sec) {
  4. $time .= sprintf('%02d', floor($secs / $sec)).($i < 2 ? ':' : '');
  5. $secs = $secs % $sec;
  6. }
  7. return $time;
  8. }

Report this snippet  

You need to login to post a comment.