/**
* 计算几分钟前、几小时前、几天前
*
* @param $time
* @return string
*/
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.'前';
}
}
}
PHP将时间戳格式化为几分钟前、几小时前、几天前
版权归原作者所有,如有侵权请告知。达维营-前端网 » PHP将时间戳格式化为几分钟前、几小时前、几天前
相关推荐
- Flashfxp文件传输到服务器后部分文件代码报错
- php7.4报错:Trying to access array offset on value of type null
- Thinkphp切换php版本报错:implode(): Passing glue string after array is deprecated. Swap the parameters
- php报错:Parse error: syntax error, unexpected end of file;Parse error: syntax error, unexpected end of file “]”
- getimagesize(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed - php end,array_shift,array_pop Only variables can be passed by reference
- laravel常用插件库
- Function create_function() is deprecated