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.89k stars 339 forks source link

timestamp issue #15

Closed kingktulu closed 12 years ago

kingktulu commented 12 years ago

Passing a timestamp to getRunDate, PHP needs the Timezone set if you are not dealing in UTC.

Simple fix, just add the last line below. Fixed all my troubles.

protected function getRunDate($currentTime = null, $nth = 0, $invert = false, $allowCurrentDate = false)
{
    $currentDate = $currentTime instanceof DateTime
        ? $currentTime
        : new DateTime($currentTime ?: 'now');

    $currentDate->setTimezone(new DateTimeZone(date_default_timezone_get()));
mtdowling commented 12 years ago

Thanks for the report. Could you submit a PR for the fix and add test coverage? Thanks!