I'm trying to insert date of birth from users into the MySQL database. However when I try to insert into the database it comes up with dateofbirth '0000-00-00'. The age function does work and it is just the date of birth field that won't function. It will still let me add the remaining fields. I tried $datetime1 as a way of using
Code:
$dateofbirth = $year .'-'. $month .'-'. $day;
$date = date("Y-m-d");
$datetime1 = date_create($dateofbirth);
$datetime2 = date_create($date);
$interval = date_diff($datetime1, $datetime2);
$age = $interval->format('%y');
$update = mysql_query("UPDATE users SET dateofbirth = '$dateofbirth', age = '$age' WHERE uid = '$uid'");
Comment