比如秒数时间很长,可以通过这段代码转换成几年几月几日的形式
/**
* PHP将秒数转换成可读性良好的格式
*
* @param
* @author 网: www.jb51.cc
**/
$time = time() - $time;
$points = array(
'year' => 31556926,'month' => 2629743,'week' => 604800,'day' => 86400,'hour' => 3600,'minute' => 60,'second' => 1
);
foreach($points as $point => $value)
{
if($elapsed = floor($time/$value) > 0)
{
$s = $elapsed>1?'s':'';
$timestamp = "$elapsed $point$s";
break;
}
}
/*** 来自编程之家 jb51.cc(jb51.cc) ***/