Bootstrap DatTimePicker set Current Date
Hi
I had to set the current date for BootStrap Date Time Picker in YYYY-MM-DD formet
Given code assist me to do it .
JS
$('#date').datetimepicker({
pickDate: true,
pickTime: false,
});
//After create control
var dNow = new Date();
var localdate = dNow.getFullYear()+'-'+ (dNow.getMonth() + 1) + '-' + dNow.getDate() ;
$('#datet').val(localdate);
HTML
<div class='input-group date' id='date' value="" data-date-format="YYYY-MM-DD">
<input type='text' id="datet" name="datet" />
<span class="input-group-addon"><span></span>
</span>
</div>
I had to set the current date for BootStrap Date Time Picker in YYYY-MM-DD formet
Given code assist me to do it .
JS
$('#date').datetimepicker({
pickDate: true,
pickTime: false,
});
//After create control
var dNow = new Date();
var localdate = dNow.getFullYear()+'-'+ (dNow.getMonth() + 1) + '-' + dNow.getDate() ;
$('#datet').val(localdate);
HTML
<div class='input-group date' id='date' value="" data-date-format="YYYY-MM-DD">
<input type='text' id="datet" name="datet" />
<span class="input-group-addon"><span></span>
</span>
</div>
Comments
Post a Comment