PHP 笔记
Bzing_1991
这个作者很懒,什么都没留下…
展开
-
PHP - 不四舍五入保留小数点后一位
$num = 1234.567; $res = sprintf('%.1f',$num); echo $res; ?> 输出结果:1234.5 若保存两位小数,则:sprintf('%.2f',$num);原创 2016-10-25 14:08:24 · 963 阅读 · 0 评论 -
PHP - 时间过去多少小时/分钟/秒
public function actionIndex(){ $time = xxx; //发布文章的时间 return $this->format_date($time); } //获取发布文章后过了多长时间 function format_date($time){ $t = time()-$time; $f = array( '31536000'=>'年', '259原创 2016-10-25 14:23:49 · 1983 阅读 · 0 评论