У меня есть этот timestamp php-код, который не отображает правильное время. он всегда показывает 8 часов назад, когда время должно быть минут назад.Преобразование timestamp ко времени назад в PHP
/**
* Convert a timestap into timeago format
* @param time
* @return timeago
*/
public static function timeago($time, $tense = "ago"){
if(empty($time)) return "n/a";
$time=strtotime($time);
$periods = array("second", "minute", "hour", "day", "week", "month", "year", "decade");
$lengths = array("60","60","24","7","4.35","12","10");
$now = time();
$difference = $now - $time;
for($j = 0; $difference >= $lengths[$j] && $j < count($lengths)-1; $j++) {
$difference /= $lengths[$j];
}
$difference = round($difference);
if($difference != 1) {
$periods[$j].= "s";
}
return "$difference $periods[$j] $tense ";
}
я не понимаю, почему он не работает должным образом
что вход и выход, что вы ожидаете ? – naomik
использовать зависимость от углерода, это облегчит вам –