mtdowling / cron-expression

CRON for PHP: Calculate the next or previous run date and determine if a CRON expression is due
http://mtdowling.com/blog/2012/06/03/cron-expressions-in-php/
MIT License
4.9k stars 335 forks source link

getMultipleRunDates #170

Closed lucatacconi closed 5 years ago

lucatacconi commented 5 years ago

hi Mtdowling,

i'm using getMultipleRunDates to extimate crontab date during a month. i setup CronExpression in this way:

$cron = Cron\CronExpression::factory(' 1');

then i tried to read next crontab execution with this script part:

$row["next_run"] = $cron->getNextRunDate()->format('Y-m-d H:i:s'); $row["next_run_lst"] = []; $aRUNs = $cron->getMultipleRunDates(30, date("Y-m-01 00:00:00"), false, true); foreach($aRUNs as $aRUN_key => $aRUN){ $row["next_run_lst"][] = $aRUN; }

The result is:

Array ( [next_run] => 2019-09-09 00:00:00 [next_run_lst] => Array ( [0] => 2019-09-02 00:00:00 [1] => 2019-09-02 00:01:00 [2] => 2019-09-02 00:02:00 [3] => 2019-09-02 00:03:00 [4] => 2019-09-02 00:04:00 [5] => 2019-09-02 00:05:00 [6] => 2019-09-02 00:06:00

if i modify initial setup with $cron = Cron\CronExpression::factory('0 0 1'); the result is OK.

Array ( [next_run] => 2019-09-09 00:00:00 [next_run_lst] => Array ( [0] => 2019-09-02 00:00:00 [1] => 2019-09-09 00:00:00 [2] => 2019-09-16 00:00:00 [3] => 2019-09-23 00:00:00 [4] => 2019-09-30 00:00:00

It seams there is something wrong with weekday setup only and getMultipleRunDates

dragonmantank commented 5 years ago

Hello @lucatacconi !

This repo is no longer maintained, and has moved to https://github.com/dragonmantank/cron-expression. It is still here for legacy reasons like older versions of Laravel.

If possible, please try against the latest version of the library, and submit a ticket over on the new repo. Thanks!