$dateTo) { return $dates; } if (1 != $dateFrom->format('N')) { $dateFrom->modify('next monday'); } while ($dateFrom <= $dateTo) { $dates[] = $dateFrom->format('Y-m-d'); $dateFrom->modify('+1 week'); } return $dates; } // Historique: // 23/08/2016 - $date_from = 2015-01-01; $date_to = 2015-02-28; // 24/08/2016 - $date_from = 2015-02-28; $date_to = 2015-04-30; // 25/08/2016 - $date_from = 2015-04-30; $date_to = 2015-06-30; // 25/08/2016 - $date_from = 2015-06-30; $date_to = 2015-08-31; // 29/08/2016 - $date_from = 2015-08-31; $date_to = 2015-10-31; // 30/08/2016 - $date_from = 2015-10-31; $date_to = 2015-12-31; // 31/08/2016 - $date_from = 2015-12-31; $date_to = 2016-02-29; // 01/09/2016 - $date_from = 2016-02-29; $date_to = 2016-04-30; // 02/09/2016 - $date_from = 2016-04-30; $date_to = 2016-06-30; // 02/09/2016 - $date_from = 2016-06-30; $date_to = 2016-08-14; // 08/09/2016 - $date_from = 2016-05-31; $date_to = 2016-07-31; // 08/09/2016 - $date_from = 2016-03-31; $date_to = 2016-05-31; // 08/09/2016 - $date_from = 2016-01-31; $date_to = 2016-03-31; // 09/09/2016 - $date_from = 2015-12-31; $date_to = 2016-01-31; // 09/09/2016 - $date_from = 2015-10-31; $date_to = 2015-12-31; // 09/09/2016 - $date_from = 2015-08-31; $date_to = 2015-10-31; // 09/09/2016 - $date_from = 2015-06-30; $date_to = 2015-08-30; // 15/09/2016 - $date_from = 2015-03-01; $date_to = 2015-04-30; // 15/09/2016 - $date_from = 2015-01-01; $date_to = 2015-02-24; $date_from = '2015-01-01'; $date_to = '2015-02-24'; $mondays = getMondaysInRange($date_from, $date_to); foreach ($mondays as $key => $monday) { echo $monday."\n"; echo exec('php cron_weekly_stats.php '.$monday.' 2> /dev/null'); } exit;