title: Update a datetime variable in mysql
body: <p>I'm trying to update my MySQL database with a <code>DateTime</code> variable.</p>
  
  <pre><code>$interval = 'P' . $days . 'DT' . $hours. 'H' . $minutes. 'M' . $seconds . 'S'  ;
  $date = new DateTime("NOW");
  $date-&gt;add(new DateInterval($interval));
  </code></pre>
  
  <p>Now the SQL update:</p>
  
  <pre><code>$query = "UPDATE table
  SET table.table_date = '$date' ";
  mysql_query($query);
  mysql_query($query);
  </code></pre>
  
  <p>If I <code>var_dump</code> the <code>$date</code> variable, it shows the right properties:</p>
  
  <pre class="lang-none prettyprint-override"><code>object(DateTime)#4 (3) { ["date"]=&gt; string(19) "2012-07-05 20:04:14" ["timezone_type"]=&gt; int(3) ["timezone"]=&gt; string(13) "Europe/Berlin" }
  </code></pre>
  
  <p>but it just wont be inserted. If I try NOW() instead of $date, it works perfectly. Whats my mistake?</p>