按日期递增循环

时间:2017-05-03 10:27:22

标签: php laravel

我正在尝试按新日期递增日期。但它没有显示任何结果。

$ed = strtotime($endDate);
for ($i = $ed; $i <= strtotime($today); $i = $ed) {
    $toArray['d'] = $ed;
    $startDate = date('y-m-d', strtotime("+1 day", strtotime($endDate)));
    $endDate = date('y-m-d', strtotime("+13 day", strtotime($startDate)));
    $ed = strtotime($endDate);
}

它不起作用。
什么错了..?

1 个答案:

答案 0 :(得分:1)

        $endDate='2017-06-21';
        $endDate='2017-05-05';
        $ed = strtotime($endDate);
        for($i = $ed; $i >= strtotime($today); $i = $ed ){
            $toArray['d'] = $ed;
            $startDate = date('y-m-d', strtotime("+1 day", strtotime($endDate)));
            $endDate = date('y-m-d', strtotime("+13 day", strtotime($startDate)));
            $ed = strtotime($endDate);
        }