Insert DATETIME to SQL from PHP


This question already has an answer here:

  • PHP date() format when inserting into datetime in MySQL 10 answers

I can't seem to store the datetime to the database.

public function add_post($username, $content) {
    $date = date("m/d/Y h:i A");
    $final = strtotime($date);
    $time_posted = date("m/d/Y h:i A", $final);

    $sql =" INSERT INTO POSTS (username, post_content, time_posted)
            VALUES ('$username','$content','$time_posted')";

        return $this->db->query($sql);

It looks like this in the database 0000-00-00 00:00:00

Here is my posts table: Posts table

The date-time field should be formatted as:

$time_posted = date("Y-m-d H:i:s", $final);