1

I'm using Metronic Template in my Laravel project. Here I wanted to disable past dates in datetime picker plugin. I have searched some blogs and most answers were to use minDate:0 property. But it seems this doesn't work in Metronic template. Please help me if you have experience in such case. Here is my code.

<div class="input-group date">
  <input type="text" class="form-control m-input" readonly="" name="followup_deadline" placeholder="Select date &amp; time" id="datePicker">
  <div class="input-group-append">
    <span class="input-group-text">
      <i class="la la-calendar-check-o glyphicon-th"></i>
    </span>
  </div>
</div>

And javascript/jquery code is here

$("#datePicker").datetimepicker({
            todayHighlight: !0,
            autoclose: !0,
            pickerPosition: "bottom-left",
            format: "yyyy-mm-dd hh:ii:00"
        });

Other details needed? Looking forward your kind answer.

1 Answers1

0

Hi I solved it using this format

Javascript

   let todayDate = new Date().getDate();
   let endD = new Date(new Date().setDate(todayDate));
   $('.form_datetime').datetimepicker({
      startDate : endD,
      weekStart: 7,
      todayBtn:  1,
      autoclose: 1,
      todayHighlight: 1,
   });

As you can see I have created a Date object and assigned it to startDate this then will disable all date behind the current date (even the time).

Html

<div class="input-group date form_datetime">
    <input type="text" size="16" id="datee" class="form-control" name="date_needed" required>
    <span class="input-group-btn">
        <button class="btn default date-set" type="button"><i class="fa fa-calendar"></i></button>
    </span>
</div>
Shulz
  • 508
  • 3
  • 12
  • 27