Find week days date from range of the two dates

前端 未结 9 1806
执念已碎
执念已碎 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 10:01

    $start_date = strtotime("2013-05-01");
    $last_date = strtotime("2013-08-30");
    while ($start_date <= $last_date) {
        $start_date = strtotime('+1 day', $start_date);
        if (date('N',$start_date) == 2 || date('N',$start_date) == 4){
            echo date('Y-m-d', $start_date).PHP_EOL;
        }
    }
    

提交回复
热议问题