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 eaaa09052b0..810a125f3c6 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
@@ -79,13 +79,15 @@ public function getCustomerLog()
*/
public function getCreateDate()
{
- if (!$this->getCustomer()->getCreatedAt()) {
+ $date = $this->getCustomer()->getCreatedAt();
+ if (!$date) {
return null;
}
- return $this->_getCoreHelper()->formatDate(
- $this->getCustomer()->getCreatedAt(),
+ return $this->_getCoreHelper()->formatTimezoneDate(
+ $date,
Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM,
- true
+ true,
+ false
);
}
@@ -120,7 +122,7 @@ 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('core')->formatTimezoneDate($date, Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true, false);
}
return Mage::helper('customer')->__('Never');
}
diff --git a/app/code/core/Mage/Core/Block/Abstract.php b/app/code/core/Mage/Core/Block/Abstract.php
index 13845e418f2..988331dd434 100644
--- a/app/code/core/Mage/Core/Block/Abstract.php
+++ b/app/code/core/Mage/Core/Block/Abstract.php
@@ -487,6 +487,7 @@ public function setChild($alias, $block)
public function unsetChild($alias)
{
if (isset($this->_children[$alias])) {
+ /** @var Mage_Core_Block_Abstract $block */
$block = $this->_children[$alias];
$name = $block->getNameInLayout();
unset($this->_children[$alias]);
@@ -1122,6 +1123,7 @@ 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)
diff --git a/app/code/core/Mage/Core/Helper/Data.php b/app/code/core/Mage/Core/Helper/Data.php
index 74a5409bd32..9f7cefa597e 100644
--- a/app/code/core/Mage/Core/Helper/Data.php
+++ b/app/code/core/Mage/Core/Helper/Data.php
@@ -153,23 +153,40 @@ 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
* @return string
*/
public function formatDate($date = null, $format = Mage_Core_Model_Locale::FORMAT_TYPE_SHORT, $showTime = false)
+ {
+ return $this->formatTimezoneDate($date, $format, $showTime, true);
+ }
+
+ /**
+ * Format date using current locale options and time zone.
+ *
+ * @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 formatTimezoneDate($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) {