Magento 1: How to Set up & Manage Timezone

how-to-setup-timezone-in-magento

Problem:
Customer export to csv is showing wrong time even though the server time is configured to show the correct timing. To fully resolve this issue, let's follow the following steps (in this example, we will use GMT +8, Singapore):
1. Change timezone from Admin Panel
System -> Configuration -> General -> Locale Options -> Timezone
magento-setup-timezone

2. Edit App/Mage.php and change the default timezone

  • Go to app/mage.php
  • Look for date_default_timezone_set(‘UTC’);
    and replace with
    date_default_timezone_set('Asia/Singapore);

3. Copy a file from Core to local

  • Copy app/code/core/Mage/Core/Model/Locale.php to:
    app/code/local/Mage/Core/Model/Locale.php
  • Look for line 38 “const DEFAULT_TIMEZONE = 'UTC';
  • Replace with “const DEFAULT_TIMEZONE = 'Asia/Singapore';”

Optional (if all else fail):

in app/code/local/Mage/Core/Model/Locale.php.

public function storeDate($store=null, $date=null, $includeTime=false, $format = null)
 {

    $timezone = Mage::app()->getStore($store)->getConfig(self::XML_PATH_DEFAULT_TIMEZONE);

    $date = new Zend_Date($date, $format, $this->getLocale());

    $date->setTimezone($timezone);

    if (!$includeTime) {

      $date->setHour(0)

        ->setMinute(0)
        ->setSecond(0);
    } 

 return $date;

 }

We have shown you specifically how to setup timezone in Magento. Hope you guys find this tutorial useful and see you in the next one! If you have any problems when following the instruction, don't hesitate to send us email at: [email protected]

If you guys want to be weekly updated by our newest Magento Tutorial, please subscribe MageBuzz channel on:

Youtube

Vimeo

Comments