Location: PHPKode > projects > Tin Can Jukebox > tincanjukebox/lib/j_timer.php
/*Generic timer.
-You can do multiple timers at once.
-Call startTimer("name") to start.
-Call endTimer("name") to end and print time.
function startTimer($name){
        global $TIMER_timers;
function endTimer($name,$removeOnEnd=true,$printMsg=true){
/*passing removeOnEnd false, leaves the start time in the timer, allowing you to
 recall it again, updating total time from start.
returns the text of time and prints by default
        global $TIMER_timers;
            if($removeOnEnd) unset($TIMER_timers[$name]);
            if($time>3600){//more than an hour
                $txt.="$hr hour(s) ";
            if($time>60){//more than a minute
                $txt.="$min min(s) ";
            if($time>0)$txt.="$time second(s)";
        }else echo "<br>Error; no timer started for '$name'<br>";
        if($printMsg && $txt !="") echo "<br><div class='tiny'>'$name' timer took <strong>$txt</strong>.</div><br>";
        return $txt;

function microtime_float(){//timer function
   list($usec, $sec) = explode(" ", microtime());
   return ((float)$usec + (float)$sec);
Return current item: Tin Can Jukebox