11

I'm trying to set a minDate for a jquery datepicker. but itz is not working.

$('.datepicker').datepicker({
    autoclose: true,
    todayHighlight: true,
    format: "dd-mm-yyyy",
    minDate: new Date(),
    clearBtn: true,
    multidate: false,
    multidateSeparator: ",",
    toggleActive: true
});
ReNiSh AR
  • 2,782
  • 2
  • 30
  • 42
Vincy Joseph
  • 223
  • 1
  • 3
  • 15

6 Answers6

42

For jquery datepicker use:

$(".datepicker").datepicker({
    minDate: 0
});

For Bootstrap versions use:

$(".datepicker").datepicker({
     startDate: new Date()
});
ReNiSh AR
  • 2,782
  • 2
  • 30
  • 42
  • 2
    Thankz it worked. I'm using bootstrap version bt i'm trying to use jquery minDate – Vincy Joseph Feb 21 '17 at 05:07
  • 2
    Wow thank you. I was driving myself crazy trying to use the jQuery API, only to learn from this that I was actually using the Bootstrap version. :) – Andrew Smith Mar 29 '17 at 15:09
  • 1
    yeah thanks a lot, even i came to know about this now..thanks again :) – RoshJ Oct 15 '20 at 07:32
  • 1
    It looks like the Bootstrap version (now called Tempus Dominus) has changed at some point and now uses minDate as well: https://getdatepicker.com/5-4/Options/#mindate – Gabe Oct 13 '21 at 19:54
5

In newer bootstrap datepicker version use below method

limiting end date **eg** +1d, +3m, +5y , -1d , -3m, -5y
limiting start date **eg**  +1d, -23d, +3m ,2y, -2y 
$('#dob').datepicker({
            fautoclose: true,
            startDate: '+1y',
   });

 $('#dob').datepicker({
            fautoclose: true,
            endDate: '-18y',
   });
Syed Shibli
  • 992
  • 1
  • 12
  • 15
2

to disable past dates use startDate instead of minDate. like this...

$('#checkinDate').datepicker({
        format: "dd/mm/yyyy",
        autoclose: true,
        startDate: new Date()
    });
0

Try to change minDate to 0

$('.datepicker').datepicker({
    autoclose: true,
    todayHighlight: true,
    format: "dd-mm-yyyy",
    minDate: 0,
    clearBtn: true,
    multidate: false,
    multidateSeparator: ",",
    toggleActive: true });
anjaneyulubatta505
  • 10,713
  • 1
  • 52
  • 62
0

According to jQuery datepicker api doc http://api.jqueryui.com/datepicker/#option-minDate, if you want to set today as minDate then minDate should be 0.

here is the working fiddle: http://jsfiddle.net/0dn4mtxn/1/

Try this:

$('.datepicker').datepicker({
    autoclose: true,
    todayHighlight: true,
    format: "dd-mm-yyyy",
    minDate: 0,
    clearBtn: true,
    multidate: false,
    multidateSeparator: ",",
    toggleActive: true
});
Monzurul Shimul
  • 8,132
  • 2
  • 28
  • 42
-1

you can use php date function like this:

this is workingg..↓

      $(document).ready(function(){
          $('#Sdate').datetimepicker({
            minDate:'<?php echo  date('Y-m-d H:i:s');?>'

          });
       });

or you can use this

       $(document).ready(function(){
          $('#Sdate').datetimepicker({
            minDate: new Date()

          });
       });