Jay
Jay

Reputation: 3082

jQuery date format not set in correct format for application

I have added jQuery datepicker to my MVC4 application so that on click of a text box a calendar control appears and from the selection the date is posted into the textbox in the format MM/DD/YYYY

I want to return this in the format DD/MM/YYYY but have been unable to do so. My code is as follows:

<script type="text/javascript">
  $(document).ready(function () {
    $('#expirydate').datepicker()
      .datepicker({ dateFormat: 'dd/mm/yy' });
  });
</script>

What am I doing wrong here? If I try to post in the format MM/DD/YYYY then my application is throwing in invalid date error

Upvotes: 0

Views: 548

Answers (1)

asymptoticFault
asymptoticFault

Reputation: 4529

Change

.datepicker({ dateFormat: 'dd/mm/yy' });

to

.datepicker({ dateFormat: 'dd/mm/yyyy' });

Upvotes: 1

Related Questions