The html input:
<input name="week_ending" type="text" id="week_ending" value="" />
The jQuery:
<script>
$(function() {
$( "#week_ending" ).datepicker();
});
</script>
The PHP code:
$week_ending = db_quote($_POST['week_ending']);
function db_quote($value) {
$connection = db_connect();
return "'" . mysqli_real_escape_string($connection,$value) . "'";
}
The SQL:
$result = db_query("INSERT INTO `timesheets` (clientid, candid, weekending, department, orderno, basicpay, basiccharge, otpay, otcharge, ot2pay, ot2charge, status, hue, huc) VALUES ($client, $cand, $week_ending, $department, $order_no, $basic_pay, $basic_charge, $ot_pay, $ot_charge, $ot2_pay, $ot2_charge, $status, $hue, $huc)");
if($result){
print 'Success! ID of last inserted record is';
}
else {
die('Error : ' . db_error());
}
Every row I insert to timesheets has the date as 0000-00-00. The data type is set to date in the timesheets table.
When inspecting the element after a date has been chosen the HTML is:
<input class="hasDatepicker" name="week_ending" id="week_ending" value="" type="text">
I'm guessing that explains the 0000-00-00 going into the database. I've tried to add .formatDate but that doesn't seem to make a difference and tried changing to <input type="date"> but still nothing is appearing in the value property
.datepicker({dateFormat: "yy-mm-dd"})$( "#week_ending" ).datepicker().formatDate( "yy-mm-dd");didn't?? Thanks