I have an application for reserving PHP + JQUERY numbers. I use the datepicker widget to select a date, and I ran into a problem. I am trying to convert the selected date (in dd / mm / yyyy format) to YYYY-mm-dd format to insert it into my database. When I select the first dates, it converts well, but when I select other dates, I see the date 1969-12-31. Here is my JQUERY code:
$(function() { $( "#datepicker" ).datepicker({ showOn: "button", buttonImage: "images/calendar.gif", buttonImageOnly: true, minDate: 0, maxDate: "+3W", dateFormat: "dd/mm/yy", beforeShowDay: function (date) { var day = date.getDay(); return [(day == 0 || day == 1 || day == 2 || day == 3 || day == 4), '']; }, onSelect: function(dateText) { $("#registration").load("room.php #registration", {selectedDate: dateText}, function() { $( "input:submit, a, button", ".registration" ).button(); $( "a", ".registration" ).click(function() { return false; }); }); } }); });
And then I repeat the result for testing:
<?php if(isset($_POST['selectedDate'])) { $selectedDate=$_POST['selectedDate']; echo date('Ym-d',strtotime((string)$selectedDate)); } ?>
Here is the image in my application: http://oi43.tinypic.com/29tv2c.jpg
1 : 
source share