Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2004
    Posts
    64,748
    Blog Entries
    6
    Plugin Contributions
    74

    Default date.timezone patch for v1.5.1/1.5.0/1.3.9 on PHP 5.3/5.4/5.5

    PHP 5.3 changed the PHP configuration requirements for date/timezone handling, and tons of PHP servers are incorrectly configured with invalid (usually missing or number-based instead of name-based) timezones.

    If you are getting the following error, you can fix it by creating your own patch files as described below:

    Symptom:
    PHP Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EDT/-5.0/EST' instead in ...

    Solution:
    Place the following code into 2 NEW files you'll create on your server:
    1. /includes/extra_configures/datetime_patch_for_v151_or_older.php
    2. /YOUR_ADMIN_FOLDER/includes/extra_configures/datetime_patch_for_v151_or_older.php
    NOTE: BOTH files require the same content:
    Code:
    <?php
    /*
     * Get time zone info from PHP config
    */
    if (version_compare(PHP_VERSION, 5.3, '>='))
    {
      @date_default_timezone_set(date_default_timezone_get());
    }

    IF THAT DOES NOT WORK, THEN ...
    "Plan B" would be to replace date_default_timezone_get() above with your actual timezone like this:

    @date_default_timezone_set('Europe/Oslo');


    IF THAT STILL DOES NOT WORK ... THEN YOU HAVE A BIGGER SERVER PROBLEM!
    If you continue to get errors related to date.timezone after following these instructions, then you must contact your hosting company for help in properly setting date.timezone in your server's PHP configuration. You will have to solve it with their help.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  2. #2
    Join Date
    Jan 2004
    Posts
    64,748
    Blog Entries
    6
    Plugin Contributions
    74

    Default Re: date.timezone patch for v1.5.1/1.5.0/1.3.9 on PHP 5.3/5.4/5.5

    Some people have reported that the above approach did not work satisfactorily for them.
    So here's an alternative:

    A. If you're already using ZC v1.5.2 or newer, the following IS ALREADY BUILT-IN! So skip step B here, and go to the instructions in C below.

    B. Delete the 2 files from the previous post above, and create the following 2 files instead:

    1. /admin/includes/extra_configures/use_catalog_time_zone.php
    Code:
    <?php
    /**
     * @package admin
     * @copyright Copyright 2003-2013 Zen Cart Development Team
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     * @version GIT: $Id: Author: DrByte  Sat Nov 2 01:21:28 2013 -0400 New in v1.5.2 $
     */
    // get time zone settings from catalog-side file
    include (DIR_FS_CATALOG . '/includes/extra_configures/set_time_zone.php');
    2. /includes/extra_configures/set_time_zone.php
    Code:
    <?php
    /**
     * @package initSystem
     * @copyright Copyright 2003-2013 Zen Cart Development Team
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     * @version GIT: $Id: Author: DrByte  Sat Nov 2 01:21:28 2013 -0400 New in v1.5.2 $
     */
    /*
     * Set time zone
    */
    if (version_compare(PHP_VERSION, 5.3, '>='))
    {
      // put your timezone here. Refer to http://www.php.net/manual/en/timezones.php
      $TZ = '';  // eg: 'Europe/Oslo'
    
    
    
    
    
    
      /**
       * MAKE NO CHANGES BELOW THIS LINE
       *
       * The following will take the timezone you specified above and apply it in your store.
       * If you didn't specify one, it will try to use the setting from your server's PHP configuration
       */
      if ($TZ == '') {
        $TZ = date_default_timezone_get();
      }
      if ($TZ != '') {
        putenv('TZ=' . $TZ);
        @date_default_timezone_set($TZ);
      }
    }
    The line highlighted in red is described below:

    C. To set your store to use the correct timezone, simply edit the line shown in red above (in set_time_zone.php), to reflect your desired timezone.


    If you're using a Zen Cart version older than v1.5.4, it's time to upgrade!
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

 

 

Similar Threads

  1. v151 cant start install get error : date.timezone not set in php.ini.
    By spidermn in forum Installing on a Linux/Unix Server
    Replies: 3
    Last Post: 23 Aug 2013, 03:32 AM
  2. ERROR: date.timezone not set in php.ini
    By shilo in forum Installing on a Linux/Unix Server
    Replies: 14
    Last Post: 22 Mar 2013, 10:26 PM
  3. v150 ERROR: date.timezone not set in php.ini
    By merlin57 in forum Installing on a Linux/Unix Server
    Replies: 7
    Last Post: 30 Dec 2012, 01:47 AM
  4. v150 Date.Timezone php.ini problems...
    By b14speedfreak in forum Installing on a Linux/Unix Server
    Replies: 6
    Last Post: 16 Aug 2012, 10:41 PM
  5. PHP.ini date timezone issue
    By meteoros in forum Installing on a Linux/Unix Server
    Replies: 4
    Last Post: 25 Feb 2012, 07:03 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR