0

I am using Laravel 10.x and I am running artisan command using Cronjob /opt/alt/php82/usr/bin/php artisan schedule:run >/dev/null 2>&1 every minute as follows:


namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
    /**
     * Define the application's command schedule.
     */
    protected function schedule(Schedule $schedule): void
    {
        $schedule->command('emails:send-scheduled')->everyMinute();
        $schedule->command('emails:send-order-reminder')->everyFiveMinutes();
        
    }

    /**
     * Register the commands for the application.
     */
    protected function commands(): void
    {
        $this->load(__DIR__.'/Commands');

        require base_path('routes/console.php');
    }
}


And commands are executed just fine. But I warning is logged in error_log file

PHP Warning:  PHP Startup: Invalid date.timezone value '', using 'UTC' instead in Unknown on line 0

I have configured timezone (Europe/Zagreb) in app settings and correct time is shown across the app. It's just when ever artisan is exexuted it's not picking up timezone and warning is logged.

I am running app on cPanel and I have already tried with setting timezone in htaccess file and as well creating php.ini files to override it. I have tried adding ini_set('date.timezone', 'Europe/Zagreb'); to artisan and different files to force timezone but no joy.

Does anyone have any suggestions?

4
  • Is it possible that your config is cached? Try to run php artisan config;cache to see if that helped Commented Jul 7, 2024 at 19:58
  • I have tried that as well and no joy Commented Jul 7, 2024 at 20:59
  • The "timezone" value in config/app.php can lead to this warning message. Can you confirm it is in the list of supported timezones at php.net/manual/en/timezones.php ? Commented Jul 7, 2024 at 21:08
  • Yes confirming that it's in the list and I have it set as: 'timezone' => 'Europe/Zagreb', Commented Jul 7, 2024 at 21:57

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.