2

Following issue wiht 1.8 CE:

enter image description here

When I’m trying to save CMS custom design info:

  • Custom Design From
  • Custom Design To

The validation fails ( even if dates are correct )

  • I’m trying with chrome
  • I have tried to change switch my locale (english/italian) but same issue

The root of the problem looks to be the following one:

Date picker fill dates in the format DD/MM/YYYY but validator.js (line 503) fail to create the new date(v) obj. It looks like date(string) accept only date in the English/American format (MM/DD/YYYY)

Any idea how to fix this ?

I'm looking for a workaround as I'm developing an extension ...

Reference:

Inchoo: Magento: Date format troubles

Update

Some code may help to understand the scenario:

 $dateFormatIso = Mage::app()->getLocale()->getDateFormat(
        Mage_Core_Model_Locale::FORMAT_TYPE_SHORT
    );

    $fieldset->addField('date_from', 'date', array(
        'name'      => 'date_from',
        'label'     => Mage::helper('myhelper')->__('Date From'),
        'image'     => $this->getSkinUrl('images/grid-cal.gif'),
        'format'    => $dateFormatIso,
        'class'     => 'validate-date validate-date-range date-range-date-from'
    ));

    $fieldset->addField('date_to', 'date', array(
        'name'      => 'date_to',
        'label'     => Mage::helper('myhelper')->__('Date To'),
        'image'     => $this->getSkinUrl('images/grid-cal.gif'),
        'format'    => $dateFormatIso,
        'class'     => 'validate-date validate-date-range date-range-date-to'
    ));

1 Answer 1

3

It looks the above issue is only related to the SHORT date format, so a workaround is to set the format to something different.

For example the above code looks 'fix' the issue:

    $dateFormatIso = Mage::app()->getLocale()->getDateFormat(
        Mage_Core_Model_Locale::FORMAT_TYPE_LONG
    );

Probably the short format is something 'ambiguous' for the js Date function

1
  • I'm signing this as the right answer ... until someone comes up with a more accurate analysis/solution
    – Fra
    May 20, 2014 at 9:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.