get last 3 months from current month using php

后端 未结 4 1124
[愿得一人]
[愿得一人] 2021-01-27 19:58

I want to get last 3 months name from current month. For example current month is August. So, I want the datas like these June, July, August. I have tried this code echo d

4条回答
  •  误落风尘
    2021-01-27 20:51

    That should work:

    function lastThreeMonths() {
        return array(
            date('F', time()),
            date('F', strtotime('-1 month')),
            date('F', strtotime('-2 month'))
        );
    }
    
    var_dump(lastThreeMonths());
    

提交回复
热议问题