JQuery Datepicker date format. How can I change the value from dd / mm / yyyy to dd / mm / yy?
I used JQuery Datepicker where date format is dd / mm / yyyy. I would like the date to be displayed as dd / mm / yy.
Eg. Instead of 07/15/2017, I would like the date to be shown as 07/15/17 in the datepicker.
This is how I call the JQuery datepicker, but it doesn't shape the date as per my need.
$( ".startdate" ).datepicker({
dateFormat: 'dd-mm-yy',
changeMonth: true,
changeYear: true
});
Is there a built-in parameter for this date format? Or is there a way to create a custom date format according to our own needs.
+3
source to share
3 answers
You need to do as below: -
$( ".startdate" ).datepicker({
dateFormat: 'dd/mm/y',//check change
changeMonth: true,
changeYear: true
});
Example: -
$( ".startdate" ).datepicker({
dateFormat: 'dd/mm/y',//check change
changeMonth: true,
changeYear: true
});
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha/js/bootstrap.js" data-modules="effect effect-bounce effect-blind effect-bounce effect-clip effect-drop effect-fold effect-slide"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css" />
<h1>Datepicker with Date Format (dd/mm/y) using JQuery</h1>
<p>Date picker: <input type="text" class="startdate" size="30"/></p>
<br>
Date Format : dd/mm/y
+4
source to share