Description
Whilst creating my first scheduled command, trying to list my schedules with
php artisan schedule:list
throws the error:
DateTime::setTimezone(): Argument #1 ($timezone) must be of type DateTimeZone, null given at vendor/laravel/framework/src/Illuminate/Console/Scheduling/ScheduleListCommand.php:43
changing my command to
php artisan schedule:list --timezone=Europe/London
gives:
DateTime::setTimezone(): Argument #1 ($timezone) must be of type DateTimeZone, string given at vendor/laravel/framework/src/Illuminate/Console/Scheduling/ScheduleListCommand.php:43
Steps To Reproduce:
My schedule:
$schedule->command('email:expired-licences')->weekdays()->at('08:00');
My custom command doesn't actually do anything yet.
Eventually I found a solution if I edited ScheduleListCommand.php changing:
->setTimezone($this->option('timezone', config('app.timezone')))
to
->setTimezone(new DateTimeZone($this->option('timezone', config('app.timezone'))))
but only if I use the --timezone=Europe/London switch (not sure if this is required), if not then the $this->option doesn't seem to be accepting the config('app.timezone') as a default.
Even:
$schedule->command('route:list')->weekdays()->at('08:00');
doesn't work on my system - not sure what's going on.
This was a bug in the laravel\framework\src\Illuminate\Console\Scheduling\ScheduleListCommand.php and was fixed in the v8.79.0 release