Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

datepicker disable date based on time

I have a datepicker on my website but now I want to disable days based on time. I want to achieve 2 things:

  1. I want to disable today, user should not be able to select today's date.
  2. Everyday after 2:00pm I want to disable tomorrow also.

Is it possible through jquery?

like image 690
user1561549 Avatar asked Jun 29 '26 03:06

user1561549


1 Answers

How about changing minDate according to hour of the day?

var hour = new Date().getHours();
$("element").datepicker({ minDate: hour >= 14 ? 2 : 1});
like image 157
Ole Melhus Avatar answered Jul 03 '26 12:07

Ole Melhus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!