Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

By default set specific date in datepicker

I'm implementing edit user functionality. This is my jquery code for datepicker

$('#companybegindate').datepicker({
    autoclose: true,
    dateFormat: 'yy',
    changeYear: true
});

And this is HTML

 <input type="text" class="form-control pull-right" name="companybegindate" id="companybegindate" value="">

My question is if I'm fetching any date from database , how can i set that date to datepicker by default ??

Suppose I'm getting '2016-06-20', how can I set this date to datepicker by default. Any help is much appreciated..Thanks.

like image 937
Aamir Avatar asked Mar 24 '26 09:03

Aamir


1 Answers

<input type="text" class="form-control pull-right" name="companybegindate" id="companybegindate" value="2016-06-20">

You may set date ('2016-06-20') directly to value attribute of input so it will be a default value.

Or You may use folowing to set it with java script.

$("#companybegindate").datepicker( "setDate" , "2016-06-20" );

like image 169
Maulik Kanani Avatar answered Mar 26 '26 23:03

Maulik Kanani



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!