日期时间选择器00-0000-00输出

I tried all the suggestion I read here but still it save as 00-0000-00 I hope someone will help me. The codes below will show the htm and php. the last part is the php. any help will highly appreciated

my code is:

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<script>
$(function() {
$( "#my_date" ).datepicker({ 
dateFormat: "MM/dd/yy",
defaultDate: "January/01/1970",
minDate: "January/01/1925",
maxDate: "December/31/2011",
changeMonth: true,
changeYear: true,
yearRange: "1925:2011",
onClose: function(dateText, inst) {
    var validDate = $.datepicker.formatDate( "MM/dd/yy",     $('#my_date').datepicker('getDate'));
        $('#my_date').datepicker('setDate', validDate);
    }
});
});
</script>
</head>
<body>
<form action="" method="post" id="myform">
<input name="my_date" id="my_date" type="text" value="January/01/2016" />
<tr><td><label>Add New Election</label></td>
<td><input type="text" name="idelection" value="" style="width:250px; height:34px; border:1px solid #336666;"/></td>
<td><input type="text" name="electitle" value="" style="width:250px; height:34px; border:1px solid #336666;"/></td>
</tr>
<tr>
 <td align="center"><input type="submit" value="ADD" name="submit"/></td>
 </tr>
 </form>
 </body>
 </html>

**The php part **

  <?php
  include "connection.php";
  session_start();
  $con = db();

 if(isset($_POST["submit"])){

$id = isset($_POST['idelection']) ? $_POST['idelection'] : '';
$title = isset($_POST['electitle']) ? $_POST['electitle'] : '';
$date1 = $_POST['my_date'];
$date = mysqli_real_escape_string($con,$date1);
$new_date = date('Y-m-d',strtotime($date));




$sql = 'INSERT INTO election_time (elec_id,elec_date) VALUES ("'.$_POST['idelection'].'","$new_date")';
$sql2 = 'INSERT INTO election (elec_id,elec_title) VALUES ("'.$_POST['idelection'].'","'.$_POST['electitle'].'")';

$result = mysqli_query($con,$sql);
$result2 = mysqli_query($con,$sql2);

if(!$result && !$result2){
die("Error on mysql query".mysqli_error());
}
}


?>

If you'd bothered doing any kind of basic debugging:

php > var_dump(strtotime('January/01/1970'));
bool(false)

Your date format is NOT something strtotime() recognizes, so it fails, returns boolean FALSE, which you then blindly insert into the the date(), where it is treated as integer 0, so your date is actually the Unix epoch, Jan 1, 1970.

And note that your code is wide open to sql injection attacks.

Just do one thing in your JS. If possible change your date format to this

dateFormat: "MM-dd-yy",



$(function() {
    $( "#my_date" ).datepicker({ 
    dateFormat: "MM-dd-yy",
    defaultDate: "January/01/1970",
    minDate: "January/01/1925",
    maxDate: "December/31/2011",
    changeMonth: true,
    changeYear: true,
    yearRange: "1925:2011",
    onClose: function(dateText, inst) {
        var validDate = $.datepicker.formatDate( "MM-dd-yy",$('#my_date').datepicker('getDate'));
        $('#my_date').datepicker('setDate', validDate);
}
    });
});