PHP头条
热点:

php 发布时间提示,php发布时间


<?php

//发布时间提示
function get_last_time($time)
{
    // 当天最大时间
    $todayLast = strtotime(date('Y-m-d 23:59:59'));
    $agoTimeTrue = time() - $time;
    $agoTime = $todayLast - $time;
    $agoDay = floor($agoTime / 86400);
    if ($agoTimeTrue < 60) {
        $result = '刚刚';
    } elseif ($agoTimeTrue < 3600) {
        $result = (ceil($agoTimeTrue / 60)) . '分钟前';
    } elseif ($agoTimeTrue < 3600 * 12) {
        $result = (ceil($agoTimeTrue / 3600)) . '小时前';
    } elseif ($agoDay == 1) {
        $result = '昨天 ';
    } elseif ($agoDay == 2) {
        $result = '前天 ';
    } elseif($agoDay >= 7 && $agoDay <= 14){
        $result = '上周 ';
    } elseif($agoDay >= 30 && $agoDay <= 60){
        $result = '上个月 ';
    }else {
        $format = date('Y') != date('Y', $time) ? "Y-m-d" : "m-d";
        $result = date($format, $time);
    }
    return $result;
}
echo get_last_time(time());

?>

www.phpzy.comtrue/php/23846.htmlTechArticlephp 发布时间提示,php发布时间 ?php //发布时间提示 function get_last_time($time) {     // 当天最大时间     $todayLast = strtotime(date('Y-m-d 23:59:59'));     $agoTimeTrue = time() - $time;     $agoTime = $toda...

相关文章

    暂无相关文章

PHP之友评论

今天推荐