Kboyz
Kboyz

Reputation: 189

Boostrap datepicker: How to set date and format

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

Answers (3)

Always Helping
Always Helping

Reputation: 14570

Try this:

$('.datepicker').datepicker({
     format: 'mm/dd/yyyy',
     startDate: '0d'
});

Upvotes: 1

achmad rizky
achmad rizky

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

ImranGalib
ImranGalib

Reputation: 114

take a look at this

    $(".datepicker").datepicker({
        dateFormat: "yy-mm-dd"
    });

Upvotes: 0

Related Questions