作者:一种姿态获得无可取代 | 来源:互联网 | 2017-05-13 02:17
function tranTime($time)
{
$rtime = date("m-d H:i", $time);
$htime = date("H:i", $time);
$time = time() - $time;
if ($time <60) {
$str = '刚刚';
} elseif ($time <60 * 60) {
$min = floor($time / 60);
$str = $min . '分钟前';
} elseif ($time <60 * 60 * 24) {
$h = floor($time / (60 * 60));
$str = $h . '小时前 ' . $htime;
} elseif ($time <60 * 60 * 24 * 3) {
$d = floor($time / (60 * 60 * 24));
if ($d == 1)
$str = '昨天 ' . $rtime;
else
$str = '前天 ' . $rtime;
} else {
$str = $rtime;
}
return $str;
}
function get_countdown($unix_time = '')
{
if (empty($unix_time)) return false;
if ($unix_time
以上就介绍了php时间函数,即拿即用,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。