I am trying to insert ClassID, TestID and Deadline into a database table, and it seems that the format of my date is not allowing the INSERT query to work. I've tried converting it with this method but it isn't working. When I run my function, it returns "Data cannot be inserted". When I echo $date in the function it gives: 2016-12-01
My function:
public function createAssignment($theClassID,$dueDate)
{
$testID = $_SESSION['currentTestID'];
$date = mysql_real_escape_string($_POST['dueDate']);
$date = date('Y-m-d', strtotime($date));
echo $date;
$sql="INSERT INTO settest (ClassID, TestID, Deadline) VALUES ('$theClassID', '$testID', $date)";
$result = mysqli_query($this->db,$sql) or die(mysqli_connect_errno()."Data cannot be inserted");
return $result;
}