kieranbarnes Independent PHP, WordPress & CubeCart Programmer

[Snippet] Setting the timezone for PHP 5.3

Posted on January 25, 2012

PHP 5.3 requires a time zone to be set if you do any kind of date processing.

Simply set this in your php.ini

  1. // London, England, Europe
  2. date.timezone = "Europe/London"
  3. date.default_latitude = 51.500181
  4. date.default_longitude = -0.12619

Or if you are on a shared host, you can do it in a .htaccess

  1. php_flag date.timezone = "Europe/London"
  2. php_flag date.default_latitude = 51.500181
  3. php_flag date.default_longitude = -0.12619

If all else fails, put the following in your code

  1. date_default_timezone_set('Europe/London');

Related posts

  1. [Snippet] Formatting the date in twitter XML feed
    The date in the Twitter XML feed is daft and ugly! It reads [created_at] =>...
  2. [Snippet] Simplified UK/US Date Conversion
    One of my major annoyances in PHP & MySQL world is the different formats when...
  3. [Snippet] Allow PHP in Smarty (CubeCart 5)
    Although it is generally bad practise to put PHP code directly into your (CubeCart 5)...
  4. Looping over dates in PHP
    I recently had to loop over the difference between two dates. For example to create...
  5. [Snippet] Formatting a currency string
    The Shopp ecommerce plugin for WordPress has a little annoying "feature" that returns the product...

Tagged as: , Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

(required)

No trackbacks yet.