Add X Days To Date, Excluding Weekends

前端 未结 4 1249
渐次进展
渐次进展 2020-12-17 07:01

I\'m currently developing an online subscription application. I\'m having some challenges on the part where the user will select the Number of Days to subscribe and then the

4条回答
  •  轮回少年
    2020-12-17 07:18

    Same result, shorter version:

    function addDays($days,$format="Y-m-d"){
    
        for($i=0;$i<$days;$i++){
            $day = date('N',strtotime("+".($i+1)."day"));
            if($day>5)
                $days++;
        }
        return date($format,strtotime("+$i day"));
    }
    

提交回复
热议问题