Change the Date Format to yyyy-mm-dd in Datepicker

Recently I was working on a project and there is a requirement came in front of me.

The requirement was to change the date format of input type date field. I had tried to change, but it hasn’t worked. So, I had used bootstrap datepicker.

Bootstrap datepicker is very good because it allows you to change the format as per your requirements.

So, I am going to share how you can change the date format of datepicker.

Let’s see.

Step 1. First include jQuery library

<script src=""></script> 

Step 2. Include Bootstrap Datepicker component

<script type="text/javascript" src=""></script> 

Step 3. Write markup to create an input field

<input type="text" id="from-datepicker"/>  

Step 4. Write Script to Add Datepicker Functionality

$( document ).ready(function() {
format: 'yyyy-mm-dd' //can also use format: 'dd-mm-yyyy'

Now you can change datepicker format with the above given script. If you have any query feel free to comment.

Leave a Reply

Your email address will not be published. Required fields are marked *