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

nextRunDate adds current minutes if date_default_timezone_set is set. #152

Closed gelform closed 4 years ago

gelform commented 7 years ago

I'm setting the timezone site-wide by using date_default_timezone_set('UTC');.

If this is set, some nextRunDates are wrong, seemingly randomly.

$cron = Cron\CronExpression::factory('* 20 * * * *');, then getNextRunDate() returns 2017-05-15 20:00:00 (currently correct).

$cron = Cron\CronExpression::factory('* 19 * * * *');, then getNextRunDate() returns 2017-05-15 19:44:00 (The hour is correct, but it's adding minutes).

All other hours seem to be correct.

If I comment out date_default_timezone_set('UTC');, then it works correctly.

theonedemon commented 4 years ago

up? any news ?

dragonmantank commented 4 years ago

Hello!

This is a fairly old issue, and this package has been replaced with dragonmantank/cron-expression. I would recommend upgrading to the newest version of that and see if you still have this problem.

I can say, looking at the new package, minutes are not being added to getNextRunDate(), and I will be adding in a regression test to make sure that it doesn't crop up.