Month by week of the year?

前端 未结 4 492
感动是毒
感动是毒 2021-01-22 22:30

I\'m trying to get the number of the month of the year by the number of a week of the year and the year. So for example week 1 is in january and returns 1, week 6 is in february

4条回答
  •  无人共我
    2021-01-22 22:43

    Something like this will do, this is also tested and works:

    function getMonthByNumber($number,$year)
    {
        return date("F",strtotime('+ '.$number.' weeks', mktime(0,0,0,1,1,$year,-1)));
    }
    
    echo getMonthByNumber(27,2011);
    

    Hope this helps

提交回复
热议问题