zen of coding

Make sure your app runs within the specified time zone…

Update: 8/2/2010 As red pointed out in the recent versions of cake this is handled through core.php:
http://github.com/cakephp/cakephp/blob/master/app/config/core.php#L247

For those stuck with the earlier versions of cake, but newer version of PHP (5.3+)… please see below:

Even with a simple shared hosting, the server time zone might differ from the time zone where you do business in, yet this becomes more important if you have multiple servers (perhaps even geo-distributed).

If you rely on fields like created and modified to do some basic reporting… or maybe you simply don’t wish to add/subtract server time difference against your region of business, the following one-liner will solve all your trouble.

In bootstrap.php:

date_default_timezone_set(‘America/New_York’);

This is what I have in mine, since we are running on the Eastern Standard US time.
Of course, you’d set the zone per your specific requirement.

%d bloggers like this: