46 public function __construct()
48 $this->startTime = time();
50 public function getStartTime()
52 return ($this->startTime);
66 public static function TimeAgo($timestamp)
69 $current_time = time();
72 $difference = $current_time - $timestamp;
101 for ($val =
sizeof($lengths) - 1;($val >= 0) && (($number = $difference / $lengths[$val]) <= 1); $val--);
108 $new_time = $current_time - ($difference % $lengths[$val]);
111 $number = floor($number);
115 $periods[$val] .=
"s";
118 $text = sprintf(
"%d %s ", $number, $periods[$val]);
121 if (($val >= 1) && (($current_time - $new_time) > 0))
123 $text .= self :: TimeAgo($new_time);
static TimeAgo($timestamp)