1

How to configure a widget calendar ?

I found some solutions, but can not understand clearly
How to add calendar in admin configuration options?

Can anyone review and guide me step by step please ?

1 Answer 1

1

I created calendar.js in new mymodule:

   require([
            "jquery",
            "mage/calendar"
    ], function($){
   $("#period_date_start").calendar({
      dateFormat: "M/d/yy",
      showsTime: true,
      timeFormat: "HH:mm:ss",
      sideBySide: true,
      closeText: "Done",
      selectOtherMonths: true,
      onClose: function( selectedDate ) {
        $( "#period_date_end" ).datepicker( "option", "minDate", selectedDate );
      }
   });

    $("#period_date_end").calendar({
      dateFormat: "M/d/yy",
      showsTime: true,
      timeFormat: "HH:mm:ss",
      sideBySide: true,
      closeText: "Done",
      selectOtherMonths: true, 
      onClose: function( selectedDate ) {
        $( "#period_date_start" ).datepicker( "option", "maxDate", selectedDate );
      }
   });

});
3
  • It worked for me, but can not save time(only save date). Anyone know why?
    – MrTo-Kane
    Mar 16, 2016 at 6:52
  • I debugged and saw this message: "6 TypeError: tmptime is null tmptime = tmptime.replace(/(?:HH?|hh?|mm?|ss?|[tT]{1,2}|[zZ]|[lc]|'.*?')/g, func..."
    – MrTo-Kane
    Mar 16, 2016 at 6:54
  • when time is not saved and date show 2194-4-5 12:00:00 wheni post todays date May 22, 2020 at 11:51

Your Answer

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

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