1

How to change in Magento date format for Calendar from mm / dd / yyyy to dd / mm / yyyy ?

I have tried change locale, nothing.

Also for Calendar.setup change setup setting ifFormat: "%Y-%m-%d",

All time same format.

enter image description here

enter image description here

Update

startdate_checkout_step.phtml

<?php $helper = Mage::helper('dv_subscriptions');?>
<?php $startDay = Mage::getStoreConfig('dv_subscriptions/settings/start_day');?>
<?php $days = Mage::app()->getLocale()->getOptionWeekdays(); ?>
<?php $dataObj = new DateTime();?>
<?php $dataObj->setTimestamp(strtotime('next '.$days[$startDay]['label']));?>
<form id="co-checkoutstep-form" action="">
<ul class="form-list">
    <li>
        <label for="start_date" class="required"><em>*</em><?php echo $this->__('When would you like to receive your first gourmet box')?></label>
        <div class="input-box">
            <input type="date" id="start_date" readonly="readonly" class="required-entry" style="cursor:pointer" name="start_date" min="<?php echo date('d-m-Y')?>" value="" >
            <img style="display:inline" src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN)?>/adminhtml/default/default/images/grid-cal.gif" id="start-from-button" />
        </div>
    </li>
</ul>
</form>

<script type="text/javascript">
    //<![CDATA[

    Calendar.setup({
        inputField: "start_date",
        ifFormat: "%Y-%m-%d",
        showsTime: false,
        showWeekNumber: false,
        weekNumbers: false,
        button: "start-from-button",
        align: "Bl",
        singleClick : true,

    });


    jQuery(document).ready(function() {
       var nextDeliveryDate = function () {
           var year = "<?php echo $dataObj->format('Y')?>";
           var month = "<?php echo $dataObj->format('n')?>";
           var day = "<?php echo$dataObj->format('j'); ?>";

           if (month.length == 1) {
               var nextMonth = '0'+ month;
           } else  {
               nextMonth = month;
           }
           if (day.length == 1) {
               var nextDay = '0' + day;
           } else  {
               nextDay = day;
           }
           return year + "-" + nextMonth + "-" + nextDay;
        };
        document.getElementById('start_date').value = nextDeliveryDate();
    });

    //]]>

</script>
  • in which form you need to change the format – MeenakshiSundaram R Aug 6 '15 at 13:18
  • It's on front end start_date, pause_from and start-from. Or you mean something other? – Maxim R Aug 6 '15 at 13:26
  • show your code, and which file ? – MeenakshiSundaram R Aug 6 '15 at 13:30
  • Code has been added – Maxim R Aug 6 '15 at 13:50
  • Did you get the correct date former by select the date from datepicker? – MeenakshiSundaram R Aug 6 '15 at 14:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.