diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View.php b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View.php index be686dc4eda..0f48d398283 100644 --- a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View.php +++ b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View.php @@ -78,11 +78,9 @@ public function getCustomerLog() */ public function getCreateDate() { - if ( ! $this->getCustomer()->getCreatedAt()) { - return null; - } - return $this->_getCoreHelper()->formatDate($this->getCustomer()->getCreatedAt(), - Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true); + return ($date = $this->getCustomer()->getCreatedAt()) + ? $this->formatDate($date, Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true, false) + : null; } public function getStoreCreateDate() @@ -111,11 +109,9 @@ public function getStoreCreateDateTimezone() */ public function getLastLoginDate() { - $date = $this->getCustomerLog()->getLoginAtTimestamp(); - if ($date) { - return Mage::helper('core')->formatDate($date, Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true); - } - return Mage::helper('customer')->__('Never'); + return ($date = $this->getCustomerLog()->getLoginAtTimestamp()) + ? $this->formatDate($date, Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true, false) + : Mage::helper('customer')->__('Never'); } public function getStoreLastLoginDate() @@ -218,6 +214,7 @@ public function isHidden() } /** + * @deprecated * Return instance of core helper * * @return Mage_Core_Helper_Data diff --git a/app/code/core/Mage/Core/Block/Abstract.php b/app/code/core/Mage/Core/Block/Abstract.php index 606497a9b80..35798564a26 100644 --- a/app/code/core/Mage/Core/Block/Abstract.php +++ b/app/code/core/Mage/Core/Block/Abstract.php @@ -1128,11 +1128,12 @@ public function helper($name) * @param string $date * @param string $format * @param bool $showTime + * @param bool $useTimezone * @return string */ - public function formatDate($date = null, $format = Mage_Core_Model_Locale::FORMAT_TYPE_SHORT, $showTime = false) + public function formatDate($date = null, $format = Mage_Core_Model_Locale::FORMAT_TYPE_SHORT, $showTime = false, $useTimezone = true) { - return $this->helper('core')->formatDate($date, $format, $showTime); + return $this->helper('core')->formatDate($date, $format, $showTime, $useTimezone); } /** diff --git a/app/code/core/Mage/Core/Helper/Data.php b/app/code/core/Mage/Core/Helper/Data.php index 538287948b3..e3d62ad4e8a 100644 --- a/app/code/core/Mage/Core/Helper/Data.php +++ b/app/code/core/Mage/Core/Helper/Data.php @@ -155,30 +155,32 @@ public function formatPrice($price, $includeContainer = true) /** * Format date using current locale options and time zone. * - * @param string|Zend_Date|null $date + * @param string|Zend_Date|null $date If empty, return current datetime. * @param string $format See Mage_Core_Model_Locale::FORMAT_TYPE_* constants * @param bool $showTime Whether to include time + * @param bool $useTimezone Convert to local datetime? * @return string */ - public function formatDate($date = null, $format = Mage_Core_Model_Locale::FORMAT_TYPE_SHORT, $showTime = false) + public function formatDate($date = null, $format = Mage_Core_Model_Locale::FORMAT_TYPE_SHORT, $showTime = false, $useTimezone = true) { if (!in_array($format, $this->_allowedFormats, true)) { return $date; } - if (!($date instanceof Zend_Date) && $date && !strtotime($date)) { - return ''; - } - if (is_null($date)) { - $date = Mage::app()->getLocale()->date(Mage::getSingleton('core/date')->gmtTimestamp(), null, null); + if (empty($date)) { + $date = Mage::app()->getLocale()->date(Mage::getSingleton('core/date')->gmtTimestamp(), null, null, $useTimezone); + } elseif (is_int($date)) { + $date = Mage::app()->getLocale()->date($date, null, null, $useTimezone); } elseif (!$date instanceof Zend_Date) { - $date = Mage::app()->getLocale()->date(strtotime($date), null, null); + if ($time = strtotime($date)) { + $date = Mage::app()->getLocale()->date($time, null, null, $useTimezone); + } else { + return ''; + } } - if ($showTime) { - $format = Mage::app()->getLocale()->getDateTimeFormat($format); - } else { - $format = Mage::app()->getLocale()->getDateFormat($format); - } + $format = $showTime + ? Mage::app()->getLocale()->getDateTimeFormat($format) + : Mage::app()->getLocale()->getDateFormat($format); return $date->toString($format); }