How to Schedule Laravel Cron Job Based on Timezone

How to Schedule Laravel Cron Job Based on Timezone?

In this post, I will show you how to schedule command based on timezone in laravel application. By default, Laravel’s scheduled commands use the timezone specified in the application configuration file. However, you can also configure cron jobs to run based on a specific timezone. Here are two methods to set up cron jobs with a timezone:

How to Schedule Laravel Cron Job Based on Timezone Setup Cron Job:

You can see the following URL to setup cron job in laravel:

routes/console.php

<?php

use Illuminate\Support\Facades\Schedule;

Schedule::command('send:user-mail')
         ->timezone('Asia/Kolkata')
         ->at('12:00')

Setting Timezone for All Command:

You can set specific timezone for all commands like the following way:

config/app.php

'schedule_timezone' => 'Asia/Kolkata',

I hope you it can help you. You Can Learn How To Set Timezone in Laravel?

Thank you

Leave a Reply