formatDate() returns 'medium' when called 'short' in Magento 1.9.2.3
-
10-12-2020 - |
Pregunta
I recently did an upgrade from Magento 1.8.0.0 to 1.9.2.3. Since then the Core Helper Function formatDate()
returns the 'medium'
-formatted date, even if called with 'short'
.
Example (output from magerun dev:console):
Magento 1.8.0.0:
>>> Mage::helper('core')->formatDate('2011-06-28 08:50:51', 'short')
=> "28.06.11"
>>> Mage::helper('core')->formatDate('2011-06-28 08:50:51', 'medium')
=> "28.06.2011"
Magento 1.9.2.3:
>>> Mage::helper('core')->formatDate('2011-06-28 08:50:51', 'short')
=> "28.06.2011"
>>> Mage::helper('core')->formatDate('2011-06-28 08:50:51', 'medium')
=> "28.06.2011"
As far as I can see the formatDate()
itself didn't change. Also my system configuration didn't change. Is it a bug? Can anybody reproduce? Thanks.
Solución
Since Magento CE 1.8.1.0, Mage_Core_Model_Locale::getDateFormat()
always returns a four digit year part, no matter which date format is passed in.
To create the desired output format, you need to bypass the Mage_Core_Helper_Data::formatDate()
method.
Licenciado bajo: CC-BY-SA con atribución
No afiliado a magento.stackexchange