Timezones in Laravel 4
This blog post was originally published a little while ago. Please consider that it may no longer be relevant or even accurate.
Here's something cool I didn't know about timezones in Laravel 4 - instead of just providing an offset from UTC you can use the default timezones as provided by PHP.
In your config/app.php
file, you've got the following setting by default:
Instead of UTC
you can simply substitute any of the PHP supported timezones. For example, a few of the apps I've worked on have Australia/Sydney
to keep all the times localised here, even through daylight savings.
Of course, if you really wanted you could go ahead and place a call to date_default_timezone_set()
somewhere in your app boot, but this is build cleanly into Laravel.
A blog about Laravel & Rails by Dwight Watson;
- building Roomies, myInspections & High School Notes.
- previously myRent & Flatmates.
