Each locale has different date formats. The default settings are configured in xml files located in lib\Zend\Locale\Data
. The locale is configured in backend
System > Configuration > General > Locale Options > Locale
For example, if we set the Locale to English (United Kingdom), which value is en_GB
. To look up the default date formats, look at the file lib\Zend\Locale\Data\en_GB.xml
:
<dateFormats>
<dateFormatLength type="full">
<dateFormat>
<pattern>EEEE, d MMMM U</pattern>
</dateFormat>
</dateFormatLength>
<dateFormatLength type="long">
<dateFormat>
<pattern>d MMMM U</pattern>
</dateFormat>
</dateFormatLength>
<dateFormatLength type="medium">
<dateFormat>
<pattern>d MMM U</pattern>
</dateFormat>
</dateFormatLength>
<dateFormatLength type="short">
<dateFormat>
<pattern>dd/MM/yy</pattern>
</dateFormat>
</dateFormatLength>
</dateFormats>
The value of the attribute type
corresponds to the const
in Mage_Core_Model_Locale
:
/**
* Date and time format codes
*/
const FORMAT_TYPE_FULL = 'full';
const FORMAT_TYPE_LONG = 'long';
const FORMAT_TYPE_MEDIUM= 'medium';
const FORMAT_TYPE_SHORT = 'short';
If after having set the locale in admin, and we do not see changes, refresh the cache:
System > Cache Management > click the button Flush Magento Cache
Get Locale Date Time
Mage::getSingleton('core/date')->date('d-m-Y H:i:s');
Posted by kiatng to OpenMage (2020-01-23 05:23)