<?PHP

    $statuscodes[0] = "purple";
    $statuscodes[1] = "green";
    $statuscodes[2] = "orange";
    $statuscodes[3] = "red";


    function displayDuration($enddate) {
      $timeremaining = intval($enddate);

      if ($timeremaining>0) {

        // Check for days
        if ($timeremaining > (60*60*24)) {
          $timeleft = $timeremaining % (60*60*24);
          $days = ($timeremaining-$timeleft) / (60*60*24);

              $timeremaining = $timeleft;
        }
        // Hours
        if ($timeremaining > (60*60)) {
          $timeleft = $timeremaining % (60*60);
          $hours = ($timeremaining-$timeleft) / (60*60);
              $timeremaining = $timeleft;
        }
        // Mins
        if ($timeremaining > 60) {
          $timeleft = $timeremaining % 60;
          $mins = ($timeremaining-$timeleft) / 60;
          $timeremaining = $timeleft;
        }
        $secs = $timeremaining;
        return ($days>0?"$days days ":"").($hours<10?"0":"").($hours==0?"0":"")."$hours:".($mins<10?"0":"").($mins==0?"0":"")."$mins:".($secs<10?"0":"").$secs ;
      } else {
              return "";
      }
    }



?>