Scheduling tasks using cron jobs in Laravel is a powerful way to automate repetitive processes like sending emails, cleaning up databases, or running reports. However, when working with applications that cater to users across different time zones, it becomes crucial to schedule these tasks based on the correct time zone.
In this guide, I’ll show you how to schedule cron jobs in Laravel based on specific time zones.
In this step, we'll set up a cron job.
Laravel 11 Cron Job Task Scheduling Example
You can set a specific timezone for single commands using the following command:
<?php
use Illuminate\Support\Facades\Schedule;
Schedule::command('send:user-mail')
->timezone('Asia/Kolkata')
->at('10:00')
You can set a specific timezone for all commands using the following code:
config/app.php
'schedule_timezone' => 'Asia/Kolkata',
You might also like:
In this article, we will see laravel 10 send bulk mail using a queue. Here, we will learn about how to send bulk ma...
Mar-13-2023
Hello Freinds, In this tutorial we will see laravel 8 multiple database connections. Today I will give you step by st...
Apr-19-2021
In this article, I'll show you how to read CSV files without a header in Python. Sometimes, CSV files don't have...
Sep-20-2024
In this tutorial, I will guide you through the process of changing the start date of a datepicker component in Angular 1...
Jul-03-2023