I'm having some strange issues with a simple $dob
form input and database insert with PDO into a mysql table of datatype date
.
Input Form (example):
<select name="dob-month">
<option value="1">January</option>
</select>
<select name="dob-day">
<option value="01">1</option>
</select>
<select name="dob-year">
<option>2013</option>
</select>
PHP (basic):
$data = $_POST; //passed through mvc
$day = trim($data['dob-day']);
$month = trim($data['dob-month']);
$year = trim($data['dob-year']);
$birthdate = date('Y-m-d', strtotime($year."-".$month."-".$day));
$stmt = $this->core->dbh->prepare("INSERT INTO userinfo (birthdate) VALUES (:birthdate)");
$stmt->bindParam(':birthdate', $birthdate, PDO::PARAM_STR);
$stmt->execute();
But it's giving dates without the day? so just 2013-12 work correctly but the day is always -01?
Is it to do with the select format of the date?