Skip to content
Advertisement

Setting the right timezone, server and PHP

I need to set the right timezone.
But I don’t understand if there is any difference between the PHP timezone (date_default_timezone_set()) and the Linux setting.

Suppose I run a new AWS instance from N.Virginia. The default timezone of that server should be UTC-05:00

Does this mean that I have to set UTC-05:00 inside my PHP ini config?

If I set UTC in the php.ini on a N. Virginia server does this will mean that php will convert automatically the date from UTC-05:00 (time of the server) to UTC

Advertisement

Answer

Actually, in Laravel, you can set your timezone from env.php file or directly from configapp.php for example, in configapp.php file you’ll find something like this:

'timezone' => env('APP_TIMEZONE') ?: 'UTC',

In this case, if you have an env.php environment file, then it’ll look for APP_TIMEZONE which could be something like following:

APP_TIMEZONE=Asia/Dhaka

If you don’t have an env.php file then you may replace the UTC part from 'timezone' => env('APP_TIMEZONE') ?: 'UTC' in the configapp.php file directly. You may find all timezones from here, look for yours.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement