Find week days date from range of the two dates

前端 未结 9 1814
执念已碎
执念已碎 2020-12-24 09:03
$start_date = "2013-05-01";
$last_date = "2013-08-30";

How can I get dates of tuesdays and thursdays between these two dates?

9条回答
  •  借酒劲吻你
    2020-12-24 09:43

    Please use the following function for your solution,

     function daycount($day, $startdate, $lastdate, $counter=0)
        {
            if($startdate >= $lastdate)
            {
                return $counter;
            }
            else
            {
                return daycount($day, strtotime("next ".$day, $startdate), ++$counter);
            }
        }
    
    $start_date = "2013-05-01";
    $last_date = "2013-08-30";
    
    echo "Tuesday Count - ".daycount("tuesday", strtotime($start_date), strtotime($last_date));
    echo "
    "; echo "Thursday Count - ".daycount("thursday", strtotime($start_date), strtotime($last_date));

提交回复
热议问题