過去の時間を計算する
647 ワード
/**
* $time
* @route('UserExercises/to_time')
*/
public function to_time($time)
{
$t = time() - $time == 0 ? 1 : time() - $time;
$f = array(
'31536000' => ' ',
'2592000' => ' ',
'604800' => ' ',
'86400' => ' ',
'3600' => ' ',
'60' => ' ',
'1' => ' '
);
foreach ($f as $k => $v) {
if (0 != $c = floor($t / (int)$k)) {
return $c . $v . ' ';
}
}
}