Hello! It's a great pleasure to have you visit my blog.
It's truly a fateful encounter. If you are interested in Chinese goods, we can collaborate.
I can provide you with affordable Chinese products that you can sell in your country, thereby boosting our economic income.


If you are willing to cooperate, I hope to hear from you to discuss the opportunity for collaboration.
Here is my Email: t@29ym.com
Looking forward to connecting with you and embarking on this partnership together!

php获取今日、昨日、上周、本月的起始时间戳和结束时间函数

    function find_createtime($day){
    $y = date("Y", time());
    $m = date("m", time());
    $d = date("d", time());
    if($day==1){
        //今天
        $time = date('Y-m-d',mktime(0, 0, 0, $m, $d, $y));
        $data[] = ['time','>=',$time];

    }elseif ($day==2){
        //昨天
        $beginYesterday=date('Y-m-d H:i:s',date(mktime(0,0,0,date('m'),date('d')-1,date('Y'))));
        $endYesterday=date('Y-m-d H:i:s',date(mktime(0,0,0,date('m'),date('d'),date('Y'))-1));
        $data[] = ['time','between',[$beginYesterday,$endYesterday]];

    }elseif($day==3){
        //导出本周
        $time = date('Y-m-d',strtotime("-7 days"));
        $data[] = ['time','>=',$time];

    }elseif($day==4){
        //导出上周
        $beginLastweek=date('Y-m-d H:i:s',mktime(0,0,0,date('m'),date('d')-date('w')+1-7,date('Y')));
        $endLastweek=date('Y-m-d H:i:s',mktime(23,59,59,date('m'),date('d')-date('w')+7-7,date('Y')));
        $data[] = ['time','between',[$beginLastweek,$endLastweek]];

    }elseif($day==5){
        //导出本月
        $time = date('Y-m-d H:i:s',mktime(0, 0, 0, $m, 1, $y));
        $data[] = ['time','>=',$time];
    }

    return $data;
}

php获取今日时间范围和昨日时间范围本月时间范围
使用方法:
find_createtime($day)
$day =1//PHP获取当日时间范围函数
$day =2//PHP获取昨天时间范围函数
$day =3//PHP获取本周时间范围函数
$day =4//PHP获取上周时间范围函数
$day =5//PHP获取当月本月时间范围函数

发表新评论