Search code examples
emailmagentotimezonedst

Order confirmation email shows wrong timezone in summer time


When I created an order,the order confirmation email showed me the wrong time.

  • The order created time on order list of dashboard is correct, just shows EDT.
  • The "created_at" column of "sales_flat_order" table stores the order time as UTC.
  • Order email's time is "UTC+1".
  • I do have to show the EDT time on order email.

What's wrong?

  • On the winter time, Order email showed me "UTC".
  • After Mar 11,2018(on the summer time), the order email shows me the "EDT + 5" ( same with UTC+1).

Even though i changed the default timezone on Mage.php, locale.php and config.xml, the order confirmation email showed me the EDT+1 date. It's very wired. Is there any solution?

I already matched the server time, web server time and store timezone.

  • Server timezone: EDT.
  • Web server timezone: America/New_York
  • magento timezone: America/New_York.

The time created in the email template {{var order.getCreatedAtFormated('long')}} shows us the "UTC+1". enter image description here Hope good solution.

Comments: I debugged it on local server and live site. When I get the time result on these codes, live site shows me the wrong time.

  • $order->getCreatedAt(); Local time output - UTC, Live output - UTC
  • $order->getCreatedAtStoreDate(); Local - EDT, Live - UTC+1(estimated result must be EDT as same with local server)

All sources are same because local source is a clone from live site Live site uses the external database(RDS), but local server is not.

\app\code\core\Mage\Sales\Model\Abstract.php

/**
 * Get object created at date affected with object store timezone
 *
 * @return Zend_Date
 */
public function getCreatedAtStoreDate()
{
    return Mage::app()->getLocale()->storeDate(
        $this->getStore(),
        Varien_Date::toTimestamp($this->getCreatedAt()),
        true
    );
}

Solution

  • Solved this issue. In the some modules, there were timezone reset code part. It was settled as "EST". After fixing it with UTC, the time of order email was corrected.

        //date_default_timezone_set('EST');
        date_default_timezone_set(Mage_Core_Model_Locale::DEFAULT_TIMEZONE);
    

    Solved successfully.