Is there any way I can set timezone in laravel 4 database.php configuration file (like 'timezone' => 'UTC'
)? I'm using mysql date, now and other functions which is giving me two separate time for production and development.
Thanks
The date_default_timezone_set() function sets the default timezone used by all date/time functions in the script.
1) Go to your phpinfo() page and search for Loaded Configuration File and open the php. ini file mentioned under that section. 2) Change the default timezone settings by adding your new timezone by modifying this line: date. timezone=Asia/Kolkata .
Go to app->config->app.php in your laravel directory. On line 43 you can alter the default timezone to whatever you need.
Laravel 4 default:
'timezone' => 'UTC',
Your timezone:
'timezone' => 'America/Los_Angeles',
This change will then carry over to your database migrations. Also, if you need to set different timezones based on environment settings, simply add a directory in app->config directory that corresponds to the environment name you specified (ie - "production"). Place a duplicate of "app.php" into your newly created directory and alter the timezone setting on line 43 accordingly.
Yes, you can add the following at the top of database.php, before return array:
date_default_timezone_set('UTC');
If you want to New York:
date_default_timezone_set('America/New_york');
And so on. I have tested it and works fine to me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With