Magento – Magento2 – how to configure a widget calendar

calendarmagento2widget

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 ?

Best Answer

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 );
      }
   });

});
Related Topic