欢迎大家加入创想工作室QQ群 网络瘫痪上不了网?电脑出故障?找破解软件?加入创想工作室QQ群,向大神求助,一步解决问题!QQ群号码:326338868[点此获取更多QQ群]
function tranTime($time) {
    $rtime = date("m-d H:i",$time);
    $rtime2 = date("Y-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 = '昨天 '.$htime;
        else
           $str = '前天 '.$htime;
    } elseif ($time < 60 * 60 * 24 * 7) {
        $d = floor($time/(60*60*24));
           $str = $d.' 天前 '.$htime;
    } elseif ($time < 60 * 60 * 24 * 30) {
        $str = $rtime;
    } else {
        $str = $rtime2;
    }
    return $str;
}
$w_time = time() - 3600;
$times = tranTime($w_time);
echo $times;

相关热词搜索:自定义函数PHP

© copyright 2002-2024, 22BA.COM All Rights Reserved

网站备案号:粤ICP备19114910号

ChuangXiang Design Studio - WebDesign & Internet Marketing

关于我们业务范围联系我们开心一刻网站地图

QQ群一:326338868QQ群二:78712271

QQ群三:193078177

邮箱:news@22ba.com

地址:深圳市福田区金田路现代国际大厦2606