How can I change format of jQuery Datepicker date?

I have a basic question, which I am not able to understand, How to format the date of jQuery datepicker in mm-dd-yyyy?

Here is my code

<input type="text" id="datePicker" />

jQuery code


Need output date text in MM-dd-yyyy format, how to achieve it, thanks

Asked by:- Vinnu
: 1936 At:- 4/25/2018 2:35:32 PM
jQuery jQuery UI jQuery Datepicker format

1 Answers
profileImage Answered by:- pika

When you create a datepicker, you have not mentioned any date format so you just need to mention date format also, while initializing datepicker in any input textbox, so for your above input box, jQuery code will be

   dateFormat: 'mm-dd-yy' //your date format

For other date formats, you can change jQuery code as per your need

   dateFormat: 'dd/mm/yy' //your date format



Similarly for short  date “d M, y” 

    dateFormat: 'd M, y' //output 27 April, 17

For showing full date, your date format will be  'DD, d MM, yy'

    dateFormat: 'DD, d MM, yy' //Friday, 27 April, 2018
At:- 4/27/2018 7:42:34 AM

Login/Register to answer
Register directly by posting answer/details

Full Name *

Email *

By posting your answer you agree on privacy policy & terms of use