title: How to post time value in database in PHP
body: <p>I was trying to post date value inside my database but every time I try, the date is not coming, but the auto row is working.</p>
  
  <p>Here is my PHP code:</p>
  
  <pre><code>&lt;?PHP
  mysql_connect("localhost","root","") or die("Could not connect: " . mysql_error());
  mysql_select_db("test") or die("Couldn't connect db!");
  
  $times = $_POST['times'];
  
  $id_time = date("d-m-Y",time());
  
      if($times) {
  
          $qry = "INSERT INTO test(id_date) VALUES('$id_time')";
          mysql_query($qry);
          header("Location: bbb.php");
  
      }
  
  ?&gt;
  
  
  &lt;form method="post" action="&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;"&gt;
  
      &lt;input type="submit" name="times" /&gt;
  
  &lt;/form&gt;
  &lt;div&gt;&lt;?php echo $id_time; ?&gt;&lt;/div&gt;
  </code></pre>
  
  <p>Here is my SQL code:</p>
  
  <pre><code>CREATE TABLE IF NOT EXISTS `test` (
    `id` int(11) NOT NULL,
    `id_date` date NOT NULL
  ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;
  
  --
  -- Dumping data for table `test`
  --
  
  INSERT INTO `test` (`id`, `id_date`) VALUES
  (1, '0000-00-00'),
  (2, '0000-00-00'),
  (3, '0000-00-00'),
  
  
  --
  -- Indexes for dumped tables
  --
  
  --
  -- Indexes for table `test`
  --
  ALTER TABLE `test`
    ADD PRIMARY KEY (`id`);
  
  --
  -- AUTO_INCREMENT for dumped tables
  --
  
  --
  -- AUTO_INCREMENT for table `test`
  --
  ALTER TABLE `test`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=6;
  /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
  /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
  /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
  </code></pre>