PHP获取指定日期的上个月的日期 转

PHP获取指定日期的上个月的日期

function last_month_today($time){
        $last_month_time = mktime(date("G", $time), date("i", $time),
                    date("s", $time), date("n", $time), 0, date("Y", $time));
        $last_month_t =  date("t", $last_month_time);
    
        if ($last_month_t < date("j", $time)) {
            return date("Y-m-t H:i:s", $last_month_time);
        }
    
        return date(date("Y-m", $last_month_time) . "-d", $time);
    }

posted on 2014-06-25 11:47  转转_li  阅读(685)  评论(0编辑  收藏  举报

导航