34 public function __construct()
36 $this->startTime = time();
38 public function getStartTime()
40 return ($this->startTime);
54 public static function TimeAgo($timestamp)
57 $current_time = time();
60 $difference = $current_time - $timestamp;
89 for ($val =
sizeof($lengths) - 1;($val >= 0) && (($number = $difference / $lengths[$val]) <= 1); $val--);
96 $new_time = $current_time - ($difference % $lengths[$val]);
99 $number = floor($number);
103 $periods[$val] .=
"s";
106 $text = sprintf(
"%d %s ", $number, $periods[$val]);
109 if (($val >= 1) && (($current_time - $new_time) > 0))
111 $text .= self :: TimeAgo($new_time);
static TimeAgo($timestamp)