PHPBuilder - On User-Defined Timezones in PHP

RSS Twitter

On User-Defined Timezones in PHP

by: David Whittington
September 11, 2003



PHP provides some nice date manipulation functions that work very well in combination with each other. However, they only handle dealing with the server's timezone. Adding the feature for shifting dates to a user-defined timezone can be a very unpleasant experience, as we know first hand. In this article, we discuss the problems we encountered, and present our solution.


We work for a software development company, CommNav, who amongst other things has developed a PHP based portal framework and application suite. Until recently it relied solely on PHP's built in date and timestamp manipulation functions for handling date and time values. However, in our most recent release in order to allow our users to specify their own timezones we found it necessary to use our own functions. Doing this turned out to be a bit more complicated than we at first imagined.
By allowing the user to specify a timezone, we unwittingly opened a Pandora's Box, out of which flew shrieking timestamp demons who tormented us, and drove us to the brink of insanity. We decided to write this article to serve as a warning post for travelers of this path. In it, we discuss our implementation prior to the change, our misconceptions about how PHP's time functions work, what PHP's time functions actually do, and our solution to the whole mess.

Next Page »

Comment and Contribute

Your comment has been submitted and is pending approval.

David Whittington



(Maximum characters: 1200). You have characters left.