Posted By

nkm on 04/27/10


Tagged

time format timer conversion convert seconds elapsed countDown Stopwatch


Versions (?)

Timer format


 / Published in: PHP
 

Formats a time in Numeric format into Timer format (HH:MM:SS). - Rounds values after conversion - Displays negative values (-HH:MM:SS) - Only displays the hours if necessary - Fails gracefully

  1. function timer_format($sec)
  2. {
  3. return ($sec<0?'-':'').gmdate($sec>=3600?'H:i:s':'i:s', abs(round($sec)));
  4. }

Report this snippet  

You need to login to post a comment.