In this tutorial, we will learn how to establish the TimeZone in Laravel PHP. In this post, we will manually configure our timezone in the laravel files. Simply follow the steps below:
Step 1: First, create a new Laravel project in your htdocs using the following command
composer create-project --prefer-dist laravel/laravel TimeZone |
Step 2: Now, open your Config/app.php and configure the timezone. By default, you will notice that the timezone is set to UTC
Step 3: We must now change the UTC to reflect our local timezone. Using Europe/Paris as a timezone, the config file will look like the following
Step 4: In this step, we must clear the cache. Simply execute the php artisan config: clear command to do this
Step 5: We are done, let's output our timezone. Paste the code below in your welcome.blade
$current_date_time=Carbon\Carbon:now(); echo $current_date_time; |
Output
2022-16-01 11:10:27
Article Contributed By :
|
|
|
|
737 Views |