<?php
//格式化时间,几分钟前,几小时前
function format_date($time){
$t = 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.'前';
}
}
}
echo format_date('1405959031');
?>
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn