HOW TO CHANGE FORMAT OF DATEPICKER?

Harsh kumar srivastava

Total Post:34

Points:238
Mvc  Mvc4  Razor 
C#
 218  View(s)
Ratings:
Rate this:

Hi, 

Here is my code, i want to change my date picker format in my form.

 <div class="col-md-6">
     <label for="dob">DOB</label>
         <div class='input-group date' id='datetimepicker1'>
             @Html.TextBoxFor(x => x.DOB, new { @class = "form-control", placeholder = "mm/dd/yyyy" })
                  <span class="input-group-addon">
                       <i class="fa fa-calendar" aria-hidden="true"></i>
                  </span>
              @Html.ValidationMessageFor(x => x.DOB)
          </div>
</div>
  1. Arezio Aurechio

    Post:1

    Points:7
    Re: How to change format of datepicker?

    Hi Harsh,

    Kindly add the given line of codes in your form as following :

     <div class="col-md-6">
    
         <label for="dob">DOB</label>
             <div class='input-group date' id='datetimepicker1'>
                 @Html.TextBoxFor(x => x.DOB, "{0:MM/dd/yyyy}", new { @class = "form-control", placeholder = "mm/dd/yyyy" })
                      <span class="input-group-addon">
                           <i class="fa fa-calendar" aria-hidden="true"></i>
                      </span>
                  @Html.ValidationMessageFor(x => x.DOB)
          </div>
    </div>

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!