title: DateTime is not storing in mysql database during form submission in php
body: <p>I am new to PHP and MySql. I am trying to insert simple form into MySql database. I have Apache/PHP/MySql in my machine. I am sorry if this is repetitive question. But i searched lot and not able to find the solution.</p>
  
  <p>I have 3 html input fields 'name', 'age', 'sex' and inserting it into mysql with 4 columns in the insert query. The 4th column is 'datetime' column. Below are my structure.</p>
  
  <pre><code>$date = new DateTime();
  $date = $date-&gt;format('Y-m-d H:i:s');
  $sql_query = "insert into demoform (name, age, sex, Created_On)
                values('$name', '$age', '$sex', '$date')";
  $result = $db_conn-&gt;query($sql_query);
  </code></pre>
  
  <p>But after i do the insert, php form submitted successfully. But in the table, the date column show as "0000-00-00 00:00:00".</p>
  
  <p>can anyone help me what am i doing wrong here?</p>
  
  <p>*Question updated with the table structure...</p>
  
  <pre><code>mysql&gt; show tables;
  +-------------------+
  | Tables_in_myphpdb |
  +-------------------+
  | demoform          |
  +-------------------+
  1 row in set (0.00 sec)
  
  mysql&gt; describe demoform;
  +------------+--------------+------+-----+---------+----------------+
  | Field      | Type         | Null | Key | Default | Extra          |
  +------------+--------------+------+-----+---------+----------------+
  | id         | int(11)      | NO   | PRI | NULL    | auto_increment |
  | name       | varchar(255) | YES  |     | NULL    |                |
  | age        | int(11)      | YES  |     | NULL    |                |
  | sex        | varchar(255) | YES  |     | NULL    |                |
  | Created_On | datetime     | NO   |     | NULL    |                |
  +------------+--------------+------+-----+---------+----------------+
  5 rows in set (0.00 sec)
  </code></pre>