How to add datepicker in magento 2 frontend formDisable future dates in magento datepickerMagento 2 : frontend calendar localizationAdd datepicker on frontend?How to save date in database from frontend?magento 2: How add time to datepicker in backendMagento 2 Add Datetime picker in system.xmlMagento 2 : Add Date Picker in 24 Hour Format in Admin FormDatepicker Options in Knockout JS Binding is not workingMagento 2 - Admin form datepicker not working in custom tabHow to show time chooser in datepicker on magento configurationDatepicker issue in Magento 1Magento 2 UI Form datepicker, default date and strange behaviour

How do ballistic trajectories work in a ring world?

My professor has told me he will be the corresponding author. Will it hurt my future career?

What is the shape of the upper boundary of water hitting a screen?

Will Jimmy fall off his platform?

What are some bad ways to subvert tropes?

How do I explain that I don't want to maintain old projects?

How was the website able to tell my credit card was wrong before it processed it?

How do resistors generate different heat if we make the current fixed and changed the voltage and resistance? Notice the flow of charge is constant

Those who speak do not know, those who know do not speak

What is the highest level of accuracy in motion control a Victorian society could achieve?

How to reclaim personal item I've lent to the office without burning bridges?

In layman's terms, does the Luckstone just give a passive +1 to all d20 rolls and saves except for death saves?

What purpose does mercury dichloride have in fireworks?

What was the nature of the known bugs in the Space Shuttle software?

When is one 'Ready' to make Original Contributions to Mathematics?

Can one block with a protection from color creature?

What does the multimeter dial do internally?

Shipped package arrived - didn't order, possible scam?

What do you call a situation where you have choices but no good choice?

How did the IEC decide to create kibibytes?

What does "spinning upon the shoals" mean?

How to say "is going" in Russian in "this game is going to perish"

force:lightningQuickAction . Will implementing this open the component as modalpop up directly?

Is it ok for parents to kiss and romance with each other while their 2- to 8-year-old child watches?



How to add datepicker in magento 2 frontend form


Disable future dates in magento datepickerMagento 2 : frontend calendar localizationAdd datepicker on frontend?How to save date in database from frontend?magento 2: How add time to datepicker in backendMagento 2 Add Datetime picker in system.xmlMagento 2 : Add Date Picker in 24 Hour Format in Admin FormDatepicker Options in Knockout JS Binding is not workingMagento 2 - Admin form datepicker not working in custom tabHow to show time chooser in datepicker on magento configurationDatepicker issue in Magento 1Magento 2 UI Form datepicker, default date and strange behaviour






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








5















I want to add a datepicker in magento 2 payment method form . Anybody have an idea how to add date picker through knockout js and data-bind in html page please help me on this ?










share|improve this question




























    5















    I want to add a datepicker in magento 2 payment method form . Anybody have an idea how to add date picker through knockout js and data-bind in html page please help me on this ?










    share|improve this question
























      5












      5








      5


      1






      I want to add a datepicker in magento 2 payment method form . Anybody have an idea how to add date picker through knockout js and data-bind in html page please help me on this ?










      share|improve this question














      I want to add a datepicker in magento 2 payment method form . Anybody have an idea how to add date picker through knockout js and data-bind in html page please help me on this ?







      magento2 datepicker






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 18 '16 at 12:44









      rajat kararajat kara

      6715 silver badges24 bronze badges




      6715 silver badges24 bronze badges




















          3 Answers
          3






          active

          oldest

          votes


















          13














          you can use the magento 2 datepicker.
          It use the jquery_ui datepicker.



          Try this in your phtml:



          <script type="text/javascript">
          require([
          "jquery",
          "mage/calendar"
          ], function($)
          $('#datepicker').datepicker(
          prevText: '<zurück', prevStatus: '',
          prevJumpText: '<<', prevJumpStatus: '',
          nextText: 'Vor>', nextStatus: '',
          nextJumpText: '>>', nextJumpStatus: '',
          monthNames: ['Januar','Februar','März','April','Mai','Juni',
          'Juli','August','September','Oktober','November','Dezember'],
          monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun',
          'Jul','Aug','Sep','Okt','Nov','Dez'],
          dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
          dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
          dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
          showMonthAfterYear: false,
          dateFormat:'d.m.yy'

          );
          );
          </script>


          Example with form:



          <div class="field col-sm-6 ">
          <div class="response-field-date">
          <div class="subtemplate-wrapper">
          <label for="" style="" class="">Terminwunsch</label>
          <div class="row">
          <div class="input-box col-sm-12">
          <input name="terminwunsch" id="datepicker" title="Terminwunsch" value="" type="text">
          <script type="text/javascript">
          require([
          "jquery",
          "mage/calendar"
          ], function($)
          $('#datepicker').datepicker(
          prevText: '<zurück', prevStatus: '',
          prevJumpText: '<<', prevJumpStatus: '',
          nextText: 'Vor>', nextStatus: '',
          nextJumpText: '>>', nextJumpStatus: '',
          monthNames: ['Januar','Februar','März','April','Mai','Juni',
          'Juli','August','September','Oktober','November','Dezember'],
          monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun',
          'Jul','Aug','Sep','Okt','Nov','Dez'],
          dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
          dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
          dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
          showMonthAfterYear: false,
          dateFormat:'d.m.yy'

          );
          );
          </script>
          </div>
          </div>
          </div>
          </div>
          </div>





          share|improve this answer























          • already added the above script but not working .

            – rajat kara
            Nov 18 '16 at 13:26











          • Did you activate the datepicker in the backend?

            – Irv
            Nov 18 '16 at 13:29











          • How to activate the datepicker in backend ?

            – rajat kara
            Nov 21 '16 at 6:56











          • Go to the backend, click on shops->configuration->catalog->catalog and down to the last section with "custom date..." ore something like this.

            – Irv
            Nov 23 '16 at 13:37






          • 1





            It works for me!

            – Charvi Parikh
            Jun 6 '18 at 12:41


















          1














          In my Magento 2 template file, I added following code to display a date picker field :



          <?php 
          echo $block->getLayout()
          ->createBlock('MagentoCustomerBlockWidgetDob')
          ->toHtml()
          ?>





          share|improve this answer






























            0














            Yet another approach:



            <div class="field date">
            <label for="date" class="label"><span><?= $block->escapeHtml(__('Date')) ?></span></label>
            <div class="control">
            <?=
            $block->getLayout()->createBlock('MagentoFrameworkViewElementHtmlDate')
            ->setData([
            'name' => 'date',
            'id' => 'date',
            'value' => $block->escapeHtmlAttr($block->getFormData()->getDate()),
            'date_format' => 'dd-MM-y',
            'image' => $this->getViewFileUrl('Magento_Theme::calendar.png'),
            'years_range' => '-120y:c+nn',
            'max_date' => '-1d',
            'change_month' => 'true',
            'change_year' => 'true',
            'show_on' => 'both',
            'first_day' => 1
            ])
            ->toHtml()
            ?>
            </div>
            </div>





            share|improve this answer

























              Your Answer








              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "479"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: false,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              imageUploader:
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              ,
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );













              draft saved

              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f146448%2fhow-to-add-datepicker-in-magento-2-frontend-form%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              3 Answers
              3






              active

              oldest

              votes








              3 Answers
              3






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              13














              you can use the magento 2 datepicker.
              It use the jquery_ui datepicker.



              Try this in your phtml:



              <script type="text/javascript">
              require([
              "jquery",
              "mage/calendar"
              ], function($)
              $('#datepicker').datepicker(
              prevText: '<zurück', prevStatus: '',
              prevJumpText: '<<', prevJumpStatus: '',
              nextText: 'Vor>', nextStatus: '',
              nextJumpText: '>>', nextJumpStatus: '',
              monthNames: ['Januar','Februar','März','April','Mai','Juni',
              'Juli','August','September','Oktober','November','Dezember'],
              monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun',
              'Jul','Aug','Sep','Okt','Nov','Dez'],
              dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
              dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
              dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
              showMonthAfterYear: false,
              dateFormat:'d.m.yy'

              );
              );
              </script>


              Example with form:



              <div class="field col-sm-6 ">
              <div class="response-field-date">
              <div class="subtemplate-wrapper">
              <label for="" style="" class="">Terminwunsch</label>
              <div class="row">
              <div class="input-box col-sm-12">
              <input name="terminwunsch" id="datepicker" title="Terminwunsch" value="" type="text">
              <script type="text/javascript">
              require([
              "jquery",
              "mage/calendar"
              ], function($)
              $('#datepicker').datepicker(
              prevText: '<zurück', prevStatus: '',
              prevJumpText: '<<', prevJumpStatus: '',
              nextText: 'Vor>', nextStatus: '',
              nextJumpText: '>>', nextJumpStatus: '',
              monthNames: ['Januar','Februar','März','April','Mai','Juni',
              'Juli','August','September','Oktober','November','Dezember'],
              monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun',
              'Jul','Aug','Sep','Okt','Nov','Dez'],
              dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
              dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
              dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
              showMonthAfterYear: false,
              dateFormat:'d.m.yy'

              );
              );
              </script>
              </div>
              </div>
              </div>
              </div>
              </div>





              share|improve this answer























              • already added the above script but not working .

                – rajat kara
                Nov 18 '16 at 13:26











              • Did you activate the datepicker in the backend?

                – Irv
                Nov 18 '16 at 13:29











              • How to activate the datepicker in backend ?

                – rajat kara
                Nov 21 '16 at 6:56











              • Go to the backend, click on shops->configuration->catalog->catalog and down to the last section with "custom date..." ore something like this.

                – Irv
                Nov 23 '16 at 13:37






              • 1





                It works for me!

                – Charvi Parikh
                Jun 6 '18 at 12:41















              13














              you can use the magento 2 datepicker.
              It use the jquery_ui datepicker.



              Try this in your phtml:



              <script type="text/javascript">
              require([
              "jquery",
              "mage/calendar"
              ], function($)
              $('#datepicker').datepicker(
              prevText: '<zurück', prevStatus: '',
              prevJumpText: '<<', prevJumpStatus: '',
              nextText: 'Vor>', nextStatus: '',
              nextJumpText: '>>', nextJumpStatus: '',
              monthNames: ['Januar','Februar','März','April','Mai','Juni',
              'Juli','August','September','Oktober','November','Dezember'],
              monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun',
              'Jul','Aug','Sep','Okt','Nov','Dez'],
              dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
              dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
              dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
              showMonthAfterYear: false,
              dateFormat:'d.m.yy'

              );
              );
              </script>


              Example with form:



              <div class="field col-sm-6 ">
              <div class="response-field-date">
              <div class="subtemplate-wrapper">
              <label for="" style="" class="">Terminwunsch</label>
              <div class="row">
              <div class="input-box col-sm-12">
              <input name="terminwunsch" id="datepicker" title="Terminwunsch" value="" type="text">
              <script type="text/javascript">
              require([
              "jquery",
              "mage/calendar"
              ], function($)
              $('#datepicker').datepicker(
              prevText: '<zurück', prevStatus: '',
              prevJumpText: '<<', prevJumpStatus: '',
              nextText: 'Vor>', nextStatus: '',
              nextJumpText: '>>', nextJumpStatus: '',
              monthNames: ['Januar','Februar','März','April','Mai','Juni',
              'Juli','August','September','Oktober','November','Dezember'],
              monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun',
              'Jul','Aug','Sep','Okt','Nov','Dez'],
              dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
              dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
              dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
              showMonthAfterYear: false,
              dateFormat:'d.m.yy'

              );
              );
              </script>
              </div>
              </div>
              </div>
              </div>
              </div>





              share|improve this answer























              • already added the above script but not working .

                – rajat kara
                Nov 18 '16 at 13:26











              • Did you activate the datepicker in the backend?

                – Irv
                Nov 18 '16 at 13:29











              • How to activate the datepicker in backend ?

                – rajat kara
                Nov 21 '16 at 6:56











              • Go to the backend, click on shops->configuration->catalog->catalog and down to the last section with "custom date..." ore something like this.

                – Irv
                Nov 23 '16 at 13:37






              • 1





                It works for me!

                – Charvi Parikh
                Jun 6 '18 at 12:41













              13












              13








              13







              you can use the magento 2 datepicker.
              It use the jquery_ui datepicker.



              Try this in your phtml:



              <script type="text/javascript">
              require([
              "jquery",
              "mage/calendar"
              ], function($)
              $('#datepicker').datepicker(
              prevText: '<zurück', prevStatus: '',
              prevJumpText: '<<', prevJumpStatus: '',
              nextText: 'Vor>', nextStatus: '',
              nextJumpText: '>>', nextJumpStatus: '',
              monthNames: ['Januar','Februar','März','April','Mai','Juni',
              'Juli','August','September','Oktober','November','Dezember'],
              monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun',
              'Jul','Aug','Sep','Okt','Nov','Dez'],
              dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
              dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
              dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
              showMonthAfterYear: false,
              dateFormat:'d.m.yy'

              );
              );
              </script>


              Example with form:



              <div class="field col-sm-6 ">
              <div class="response-field-date">
              <div class="subtemplate-wrapper">
              <label for="" style="" class="">Terminwunsch</label>
              <div class="row">
              <div class="input-box col-sm-12">
              <input name="terminwunsch" id="datepicker" title="Terminwunsch" value="" type="text">
              <script type="text/javascript">
              require([
              "jquery",
              "mage/calendar"
              ], function($)
              $('#datepicker').datepicker(
              prevText: '<zurück', prevStatus: '',
              prevJumpText: '<<', prevJumpStatus: '',
              nextText: 'Vor>', nextStatus: '',
              nextJumpText: '>>', nextJumpStatus: '',
              monthNames: ['Januar','Februar','März','April','Mai','Juni',
              'Juli','August','September','Oktober','November','Dezember'],
              monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun',
              'Jul','Aug','Sep','Okt','Nov','Dez'],
              dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
              dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
              dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
              showMonthAfterYear: false,
              dateFormat:'d.m.yy'

              );
              );
              </script>
              </div>
              </div>
              </div>
              </div>
              </div>





              share|improve this answer













              you can use the magento 2 datepicker.
              It use the jquery_ui datepicker.



              Try this in your phtml:



              <script type="text/javascript">
              require([
              "jquery",
              "mage/calendar"
              ], function($)
              $('#datepicker').datepicker(
              prevText: '<zurück', prevStatus: '',
              prevJumpText: '<<', prevJumpStatus: '',
              nextText: 'Vor>', nextStatus: '',
              nextJumpText: '>>', nextJumpStatus: '',
              monthNames: ['Januar','Februar','März','April','Mai','Juni',
              'Juli','August','September','Oktober','November','Dezember'],
              monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun',
              'Jul','Aug','Sep','Okt','Nov','Dez'],
              dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
              dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
              dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
              showMonthAfterYear: false,
              dateFormat:'d.m.yy'

              );
              );
              </script>


              Example with form:



              <div class="field col-sm-6 ">
              <div class="response-field-date">
              <div class="subtemplate-wrapper">
              <label for="" style="" class="">Terminwunsch</label>
              <div class="row">
              <div class="input-box col-sm-12">
              <input name="terminwunsch" id="datepicker" title="Terminwunsch" value="" type="text">
              <script type="text/javascript">
              require([
              "jquery",
              "mage/calendar"
              ], function($)
              $('#datepicker').datepicker(
              prevText: '<zurück', prevStatus: '',
              prevJumpText: '<<', prevJumpStatus: '',
              nextText: 'Vor>', nextStatus: '',
              nextJumpText: '>>', nextJumpStatus: '',
              monthNames: ['Januar','Februar','März','April','Mai','Juni',
              'Juli','August','September','Oktober','November','Dezember'],
              monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun',
              'Jul','Aug','Sep','Okt','Nov','Dez'],
              dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
              dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
              dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
              showMonthAfterYear: false,
              dateFormat:'d.m.yy'

              );
              );
              </script>
              </div>
              </div>
              </div>
              </div>
              </div>






              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Nov 18 '16 at 12:58









              IrvIrv

              3761 silver badge7 bronze badges




              3761 silver badge7 bronze badges












              • already added the above script but not working .

                – rajat kara
                Nov 18 '16 at 13:26











              • Did you activate the datepicker in the backend?

                – Irv
                Nov 18 '16 at 13:29











              • How to activate the datepicker in backend ?

                – rajat kara
                Nov 21 '16 at 6:56











              • Go to the backend, click on shops->configuration->catalog->catalog and down to the last section with "custom date..." ore something like this.

                – Irv
                Nov 23 '16 at 13:37






              • 1





                It works for me!

                – Charvi Parikh
                Jun 6 '18 at 12:41

















              • already added the above script but not working .

                – rajat kara
                Nov 18 '16 at 13:26











              • Did you activate the datepicker in the backend?

                – Irv
                Nov 18 '16 at 13:29











              • How to activate the datepicker in backend ?

                – rajat kara
                Nov 21 '16 at 6:56











              • Go to the backend, click on shops->configuration->catalog->catalog and down to the last section with "custom date..." ore something like this.

                – Irv
                Nov 23 '16 at 13:37






              • 1





                It works for me!

                – Charvi Parikh
                Jun 6 '18 at 12:41
















              already added the above script but not working .

              – rajat kara
              Nov 18 '16 at 13:26





              already added the above script but not working .

              – rajat kara
              Nov 18 '16 at 13:26













              Did you activate the datepicker in the backend?

              – Irv
              Nov 18 '16 at 13:29





              Did you activate the datepicker in the backend?

              – Irv
              Nov 18 '16 at 13:29













              How to activate the datepicker in backend ?

              – rajat kara
              Nov 21 '16 at 6:56





              How to activate the datepicker in backend ?

              – rajat kara
              Nov 21 '16 at 6:56













              Go to the backend, click on shops->configuration->catalog->catalog and down to the last section with "custom date..." ore something like this.

              – Irv
              Nov 23 '16 at 13:37





              Go to the backend, click on shops->configuration->catalog->catalog and down to the last section with "custom date..." ore something like this.

              – Irv
              Nov 23 '16 at 13:37




              1




              1





              It works for me!

              – Charvi Parikh
              Jun 6 '18 at 12:41





              It works for me!

              – Charvi Parikh
              Jun 6 '18 at 12:41













              1














              In my Magento 2 template file, I added following code to display a date picker field :



              <?php 
              echo $block->getLayout()
              ->createBlock('MagentoCustomerBlockWidgetDob')
              ->toHtml()
              ?>





              share|improve this answer



























                1














                In my Magento 2 template file, I added following code to display a date picker field :



                <?php 
                echo $block->getLayout()
                ->createBlock('MagentoCustomerBlockWidgetDob')
                ->toHtml()
                ?>





                share|improve this answer

























                  1












                  1








                  1







                  In my Magento 2 template file, I added following code to display a date picker field :



                  <?php 
                  echo $block->getLayout()
                  ->createBlock('MagentoCustomerBlockWidgetDob')
                  ->toHtml()
                  ?>





                  share|improve this answer













                  In my Magento 2 template file, I added following code to display a date picker field :



                  <?php 
                  echo $block->getLayout()
                  ->createBlock('MagentoCustomerBlockWidgetDob')
                  ->toHtml()
                  ?>






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 2 '17 at 10:06









                  DependencyHellDependencyHell

                  8665 silver badges22 bronze badges




                  8665 silver badges22 bronze badges





















                      0














                      Yet another approach:



                      <div class="field date">
                      <label for="date" class="label"><span><?= $block->escapeHtml(__('Date')) ?></span></label>
                      <div class="control">
                      <?=
                      $block->getLayout()->createBlock('MagentoFrameworkViewElementHtmlDate')
                      ->setData([
                      'name' => 'date',
                      'id' => 'date',
                      'value' => $block->escapeHtmlAttr($block->getFormData()->getDate()),
                      'date_format' => 'dd-MM-y',
                      'image' => $this->getViewFileUrl('Magento_Theme::calendar.png'),
                      'years_range' => '-120y:c+nn',
                      'max_date' => '-1d',
                      'change_month' => 'true',
                      'change_year' => 'true',
                      'show_on' => 'both',
                      'first_day' => 1
                      ])
                      ->toHtml()
                      ?>
                      </div>
                      </div>





                      share|improve this answer



























                        0














                        Yet another approach:



                        <div class="field date">
                        <label for="date" class="label"><span><?= $block->escapeHtml(__('Date')) ?></span></label>
                        <div class="control">
                        <?=
                        $block->getLayout()->createBlock('MagentoFrameworkViewElementHtmlDate')
                        ->setData([
                        'name' => 'date',
                        'id' => 'date',
                        'value' => $block->escapeHtmlAttr($block->getFormData()->getDate()),
                        'date_format' => 'dd-MM-y',
                        'image' => $this->getViewFileUrl('Magento_Theme::calendar.png'),
                        'years_range' => '-120y:c+nn',
                        'max_date' => '-1d',
                        'change_month' => 'true',
                        'change_year' => 'true',
                        'show_on' => 'both',
                        'first_day' => 1
                        ])
                        ->toHtml()
                        ?>
                        </div>
                        </div>





                        share|improve this answer

























                          0












                          0








                          0







                          Yet another approach:



                          <div class="field date">
                          <label for="date" class="label"><span><?= $block->escapeHtml(__('Date')) ?></span></label>
                          <div class="control">
                          <?=
                          $block->getLayout()->createBlock('MagentoFrameworkViewElementHtmlDate')
                          ->setData([
                          'name' => 'date',
                          'id' => 'date',
                          'value' => $block->escapeHtmlAttr($block->getFormData()->getDate()),
                          'date_format' => 'dd-MM-y',
                          'image' => $this->getViewFileUrl('Magento_Theme::calendar.png'),
                          'years_range' => '-120y:c+nn',
                          'max_date' => '-1d',
                          'change_month' => 'true',
                          'change_year' => 'true',
                          'show_on' => 'both',
                          'first_day' => 1
                          ])
                          ->toHtml()
                          ?>
                          </div>
                          </div>





                          share|improve this answer













                          Yet another approach:



                          <div class="field date">
                          <label for="date" class="label"><span><?= $block->escapeHtml(__('Date')) ?></span></label>
                          <div class="control">
                          <?=
                          $block->getLayout()->createBlock('MagentoFrameworkViewElementHtmlDate')
                          ->setData([
                          'name' => 'date',
                          'id' => 'date',
                          'value' => $block->escapeHtmlAttr($block->getFormData()->getDate()),
                          'date_format' => 'dd-MM-y',
                          'image' => $this->getViewFileUrl('Magento_Theme::calendar.png'),
                          'years_range' => '-120y:c+nn',
                          'max_date' => '-1d',
                          'change_month' => 'true',
                          'change_year' => 'true',
                          'show_on' => 'both',
                          'first_day' => 1
                          ])
                          ->toHtml()
                          ?>
                          </div>
                          </div>






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Jun 28 at 8:05









                          DmitryDmitry

                          911 silver badge5 bronze badges




                          911 silver badge5 bronze badges



























                              draft saved

                              draft discarded
















































                              Thanks for contributing an answer to Magento Stack Exchange!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid


                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.

                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f146448%2fhow-to-add-datepicker-in-magento-2-frontend-form%23new-answer', 'question_page');

                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

                              Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

                              Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form