-1

i am trying to set a min time and max time for https://getdatepicker.com/4/

$mydatepicker.datetimepicker({
    minDate: moment("12/01/2015 8:50 AM"),
    maxDate: moment("12/30/2015 9:50 AM"),
    viewMode: 'days',
    format: 'DD MMMM YYYY hh:mm A',
   
});

It is not restricting to the given time if we change AM to PM its changing and the date is removed if we try to increment the minutes. Any one have idea of how to use this plugin for setting minimum date and also time?

freedomn-m
  • 27,664
  • 8
  • 35
  • 57
Sourav
  • 67
  • 1
  • 14
  • It's unlikely that bootstrap datepicker will accept a `moment` object instead of a date - either use `new Date(2015,0,12,8,50)` or `moment(...).toDate()` – freedomn-m Jan 12 '21 at 11:34

1 Answers1

0

I think that moment.js is deprecated. You could set like this with jQuery:

$('#datepicker1').datepicker({
  dateFormat: "yy-mm-dd",
  maxDate: new Date('2018-3-26')
});
// Number
$('#datepicker2').datepicker({
  dateFormat: "yy-mm-dd",
  maxDate: 2
});
// String
$('#datepicker3').datepicker({
  dateFormat: "yy-mm-dd",
  maxDate: "+1m"
});

Same implies to minDate.

Mr. Polywhirl
  • 42,981
  • 12
  • 84
  • 132
  • I wouldn't say that moment is deprecated, just "end-of-life". It is still a great library, but will be outshined by [Luxon](https://moment.github.io/luxon/) and [Temporal - TC39](https://github.com/tc39/proposal-temporal). – Mr. Polywhirl Jan 12 '21 at 16:47
  • I was able to make it work for date but when i add time into the mix, it wouldn't work as expected. for example 2018-3-26 11:59 PM. When i keep this and change the format. i am able to change the PM to AM and select it. – Sourav Jan 13 '21 at 12:38