php 判断是不是同一个月

protected function isSameMonth($time1, $time2)
    {
        $m1 = date('Ym', strtotime($time1));
        $m2 = date('Ym', strtotime($time2));
        // 必须判断年份,不然2019-8和2020-8会被认为同一月
        if($m1 == $m2){
            return true;
        }
        return false;
    }

猜你喜欢

转载自blog.csdn.net/qq_38324424/article/details/106851219