Reputation: 189
I'm using bootstrap datepicker. I'm trying to set the date with format at the same time. How do I that?
<input type="text" class="datepicker form-control" name="StartDate">
$('.datepicker').datepicker({
format: "yyyy-mm-dd",
setDate: DateValue
});
I was reading their docs but I can't find any example.
Upvotes: 0
Views: 169
Reputation: 14570
Try this:
$('.datepicker').datepicker({
format: 'mm/dd/yyyy',
startDate: '0d'
});
Upvotes: 1
Reputation: 103
You can set using attribute value
at input html.
If you use php:
<input type="text" class="datepicker form-control" name="StartDate" value="<?=date('Y-m-d');?>">
If you use jquery
and moment
plugin:
$('input[name=StartDate]').val(moment().format('YYYY-MM-DD'));
Upvotes: 1
Reputation: 114
take a look at this
$(".datepicker").datepicker({
dateFormat: "yy-mm-dd"
});
Upvotes: 0