title: Inserting or updating mysql datetime field with php
body: <p>I have a function which adds an item to the basket. In this function, it checks to see if a basket already exists for this user and creates or updates the basket accordingly. When creating or updating  the basket, I need a timeout field set to 4 hours in the future. However, when I create or update a basket, the dateTime field for the timeout is at 0000-00-00 00:00:00. Here is my code (php using the codeigniter framework):</p>
  
  <pre><code>$dateTime = date("Y-d-m h:m:s", strtotime("+4 hours"));
  
  if($query-&gt;num_rows() != 1)
  {
  
  
      $this-&gt;db-&gt;insert("baskets", array("basket_session" =&gt; session_id(), "basket_timeout" =&gt; $dateTime, "basket_delivery" =&gt; "0.00"));
  
  }
  else
  {
  
      $this-&gt;db-&gt;where("basket_session", session_id());
      $this-&gt;db-&gt;update("baskets", array("basket_timeout" =&gt; $dateTime));
  
  }
  </code></pre>
  
  <p>What am I missing?</p>