News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Joakim Nygard's Blog:
Timezones in MySQL and PHP
July 23, 2007 @ 13:43:00

On his blog today, Joakim Nygard has posted about the use (or disuse) of time zones in PHP:

The problem with not handling timezones correctly is not apparent in the usual case of the webserver and the database server being in the same timezone. [...] Often a specific timezone is assumed for displaying date and time. This could very well be incorrect for a large number of visitors. If the database server is in yet another timezone, things begin to get out of sync.

He mentions the time zone functionality that MySQL offers too, but notes that it cannot be relied on either. Thankfully, there's is a bit of hope in PHP5 (as of 5.1 in fact) - the date_default_timezine_set function. He includes an example of the function in use, making it simple to get the correct date and time automatically with the date() function without having to do any hacks to discover the correct time zone.

4 comments voice your opinion now!
timezone datedefaulttimezoneset mysql timezone datedefaulttimezoneset mysql


blog comments powered by Disqus

Similar Posts

Job Posting: Integraclick (Clickbooth.com) Seeks PHP/MySQL Developer (Sarasota/Miami, FL)

NetTuts.com: PHP Database Access: Are You Doing It Correctly?

Brent Meshier's Blog: Blocking visitors by country using PHP & MySQL

DevShed: Generating Outputs from MySQL with Static Members and Methods in PHP 5

PHPBuilder.com: Handling Hierarchical Data in MySQL and PHP


Community Events

Don't see your event here?
Let us know!


php7 version podcast interview wordpress laravel5 release voicesoftheelephpant list introduction series api extension opinion language library security laravel community framework

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework