/** * [time_format description] * @param [type] $time [发布时间] * @return [type] [处理时间] */ function time_format ($time) { //当前时间 $now = time(); //今天零时零分零秒 $today = strtotime(date('Y-m-d', $now)); //时间差 $diff = $now - $time; $str = ''; switch ($time) { case $diff < 60 : $str = $diff . '秒前'; break; case $diff < 3600 : $str = floor( $diff / 60 ) . '分钟前'; break; case $diff < (3600 * 8) : $str = floor( $diff / 3600) . '小时前'; break; case $time > $today : $str = '今天 ' . date('H:i', $time); break; default: $str = date('Y-m-d H:i:s', $time); break; } return $str; }