Laravel scheduler no timezone

Viewed 458

I am trying to make cron jobs with Laravel 8

$schedule->command('myCommand')->daily()->timezone('Europe/Paris');

I have an error when I run on server

php artisan schedule:list

php artisan schedule:list

 TypeError 

  DateTime::setTimezone(): Argument #1 ($timezone) must be of type DateTimeZone, null given

  at vendor/laravel/framework/src/Illuminate/Console/Scheduling/ScheduleListCommand.php:42
     38▕                 $event->expression,
     39▕                 $event->description,
     40▕                 (new CronExpression($event->expression))
     41▕                             ->getNextRunDate(Carbon::now()->setTimezone($event->timezone))
  ➜  42▕                             ->setTimezone($this->option('timezone', config('app.timezone')))
     43▕                             ->format('Y-m-d H:i:s P'),
     44▕             ];
     45▕         }
     46▕ 

      +14 vendor frames 
  15  artisan:37
      Illuminate\Foundation\Console\Kernel::handle()

And

php artisan schedule:run
No scheduled commands are ready to run.

Tried:

  TypeError 
    
      DateTime::setTimezone(): Argument #1 ($timezone) must be of typ
...

e(Carbon::now()->setTimezone($event->timezone))
      ➜  42▕                             ->setTimezone($this->option('timezone', config('Europe/Paris')))
         43▕                             ->format('Y-m-d H:i:s P'),
         44▕             ];
         45▕
          Illuminate\Foundation\Console\Kernel::handle()
1 Answers

I had same problem, an

Composer update

solve the problem in my side !

Related