How to find Find First Sunday of every month

前端 未结 4 877
陌清茗
陌清茗 2020-12-22 14:15

I have require first sunday date of every month using php code.

please can help me.

getSunday();
4条回答
  •  时光说笑
    2020-12-22 14:44

    function firstSunday($DATE)
        {
            $date = strftime("%Y-%m",$DATE);
            $day = trim(strftime("%e",$DATE));
    
            for($day; $day <= '7'; $day++){
                $dd = strftime("%A",strtotime($date.'-'.$day));
                if($dd == 'Sunday'){
                    return strftime("%Y-%m-%d",strtotime($date.'-'.$day));
                }
            }
        }
    

提交回复
热议问题