Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap DatePicker, how to set the start date for tomorrow?

How can I set the startDate for tomorrow? I don't see an option in the documentation for Date.today so I can add one more day.

Is there a way to accomplish this?

$(function() {     $("#appointment_adate").datepicker({         format: 'yyyy-mm-d',         autoclose: true,         startDate: '+1d'         }); }); 
like image 944
evanx Avatar asked Jan 19 '13 00:01

evanx


People also ask

How can I set start and end dates for a datepicker?

Setting an end datevar end_date = new Date(); This will set the end date (the latest selectable date) to today. To move this into the past use code like this: var start_date = new Date().

How do I change the default date in datepicker?

Syntax: $(". selector"). datepicker( {defaultDate:"+6"} );

How do I initialize a date picker?

Initialize the datepicker and specify the date format in "yyyy-mm-dd". JavaScript Code : $( "#datepicker" ). datepicker(); $( "#datepicker" ).


1 Answers

There is no official datepicker for bootstrap; as such, you should explicitly state which one you're using.

If you're using eternicode/bootstrap-datepicker, there's a startDate option. As discussed directly under the Options section in the README:

All options that take a "Date" can handle a Date object; a String formatted according to the given format; or a timedelta relative to today, eg '-1d', '+6m +1y', etc, where valid units are 'd' (day), 'w' (week), 'm' (month), and 'y' (year).

So you would do:

$('#datepicker').datepicker({     startDate: '+1d' }) 
like image 87
eternicode Avatar answered Sep 28 '22 08:09

eternicode