I have had similar issue with Date filter :)
The way date time instantiated in the form like that
Step 1:-
In Block Form class Mage_CatalogSearch_Block_Advanced_Form
public function getDateInput($attribute, $part = 'from')
{
$name = $attribute->getAttributeCode() . '[' . $part . ']';
$value = $this->getAttributeValue($attribute, $part);
return $this->_getDateBlock()
->setName($name)
->setId($attribute->getAttributeCode() . ($part == 'from' ? '' : '_' . $part))
->setTitle($this->getAttributeLabel($attribute))
->setValue($value)
->setImage($this->getSkinUrl('images/calendar.gif'))
->setFormat('%m/%d/%y') //So you need change the Format here !!!!!
->setClass('input-text')
->getHtml();
}
So you need to change the Date format for the calendar in the line ->setFormat('%m/%d/%y')
Then its used in the method below to generate the block
$block = $this->getLayout()->createBlock('core/html_date');
$this->setData('_select_block', $block);
and in that block class Mage_Core_Block_Html_Date
Line 40: $displayFormat = Varien_Date::convertZendToStrFtime($this->getFormat(), true, (bool)$this->getTime());
.......
Line53: ifFormat : "' . $displayFormat . '",
Step 2:-
In the advanced search collection class Mage_CatalogSearch_Model_Resource_Advanced_Collection
You need to modify this method to allow the new locale or the new datatime format you needed !
Line43: public function addFieldsToFilter($fields) {
.......
.......
.......
.......
Line96: if (!Zend_Date::isDate($conditionValue['from'])) {
.......
Line109:if (!Zend_Date::isDate($conditionValue['to'])) {
.......
}
Now You need to modify those 2 lines with the new datetime format you change the search block to allow this method to be validated
For instance i modified the Javascript calendar format to be %d-%m-%Y which will produce Date in the calendar like ( 25-12-2014 )
Then i modified The method in the above collection class to be like this
if (!Zend_Date::isDate($conditionValue['from'], 'd-m-Y' )) { // I added the format for the validation
.......
.......
if (!Zend_Date::isDate($conditionValue['to'], 'd-m-Y' )) { // same as above one
step 3:-
Change those value of date inputs in the class Mage_CatalogSearch_Model_Resource_Advanced_Collection
to whatever format or locale.
Everything works fine with that.
I have made small module that rewrite the 2 classes you need to modify based on the locale you need
Check it out https://github.com/Meabed/magento-advanced-search-datetime-field
Regards !
Mage_Core_Helper_Data::format()
it will format the date according to the locale settings.
Mage::helper('core')->formatDate($date->date('d F Y', $post->getCreatedTime()), 'medium', false);
reference for understanding the date better
Best Answer
You can try this:
Other date formates here: https://framework.zend.com/manual/1.10/en/zend.date.constants.html