人性化时间

7-11 2,270 views

 <?php
//人性化时间
function fn_formatdate($time){     
    $rtime = date("Y-m-d H:i",$time);     
    $htime = date("H:i",$time);           
    $time  = time() - $time;       
    if ($time < 60){         
            $formatime = '刚才';     
    }elseif($time < 60 * 60){         
            $min = floor($time/60);         
            $formatime = $min.'分钟前';     
    }elseif($time < 60 * 60 * 24){         
            $h = floor($time/(60*60));         
            $formatime = $h.'小时前';     
    }elseif($time < 60 * 60 * 24 * 3){         
            $d = floor($time/(60*60*24));         
            if($d==1){
                    $formatime = '昨天 '.$htime;
            }else{
                    $formatime = '前天 '.$htime;     
            }
    }else{         
            $formatime = $rtime;     
    }     
    return $formatime; 
}

php实现redis延时队列

写了一个简单的类实现 使用方法 $class = new RedisDelayQueue(); $class->execute(); <?php namespace app\common\service; class RedisDelay { ...

阅读全文

php获取包含10w个手机号的txt文件(逗号隔开)

txt文件格式如下 13000000000,13000000005,13000000403,13001010129,13001010688,13001010838,13001016389,13001019538,13001030005,13001042700,13001047495...

阅读全文

php使用Carbon获取2个日期之间的日期

<?php use Carbon\CarbonPeriod; $period = CarbonPeriod::create('2018-06-14', '2018-06-20'); // Iterate over the period fore...

阅读全文

欢迎留言