I needed a date picker to add into a PHP file I use to select various time ranges inside one of my database tables. I used to type this information manually but because I need to select it so often I wanted to create a faster cleaner version. I found source code for a datepicker through this website..
http://api.jqueryui.com/datepicker/#option-dateFormat
It gives me the following code to use...
<script>
$( function() {
$( "#datepicker" ).datepicker();
} );
$( function() {
$( "#datepicker2" ).datepicker();
} );
</script>
One is for the start date and the second is for the finish date, I'm trying to modify the format of the dates so they'll appear yy-mm-dd. The API documentation says I can accomplish this by using the following code...
$( ".selector" ).datepicker({
dateFormat: "yy-mm-dd"
});
// Getter
var dateFormat = $( ".selector" ).datepicker( "option", "dateFormat" );
// Setter
$( ".selector" ).datepicker( "option", "dateFormat", "yy-mm-dd" );
How do I add this to my code? Does is just go right inside the script tags? I tried putting it there and making various edits but with no success, the API docs don't detail where to add it or what to modify.
The entire source code chunk that powers this is..
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$( function() {
$( "#datepicker" ).datepicker();
} );
$( function() {
$( "#datepicker2" ).datepicker();
} );
$( ".datepicker" ).datepicker({
dateFormat: "yy-mm-dd"
});
$( ".datepicker" ).datepicker( "option", "dateFormat", "yy-mm-dd" );
</script>
<form action="dateselection.php" method="POST">
<p>Date: <input type="text" id="datepicker" name="dp"></p>
<p>Date2: <input type="text" id="datepicker2" name="dp2"></p>
<input type="submit">
</form>