title: Inserting DATETIME into MySQL
body: <p>I am having a problem inserting DATETIME into MySQL using PHP. </p>
  
  <p>First, I am fetching a date from the news table:</p>
  
  <pre><code>$statement = $db-&gt;query("SELECT utcPublishedDate FROM News WHERE idNews = $newsID");
  $row = $statement-&gt;fetch(PDO::FETCH_ASSOC);
  $utcPublishedDate = $row["utcPublishedDate"];
  </code></pre>
  
  <p>Then I am doing some date manipulation on that date due to some code requirements, eventually this date is changing to something else.</p>
  
  <p>Now, I have to update the table, so:</p>
  
  <pre><code>$statement = $db-&gt;query("UPDATE News SET utcPublishedDate = $utcPublishedDate WHERE idNews = $newsID");
  </code></pre>
  
  <p>This is causing an error. If I do this:</p>
  
  <pre><code>$statement = $db-&gt;query("UPDATE News SET utcPublishedDate = NOW() WHERE idNews = $newsID");
  </code></pre>
  
  <p>The statement will execute without a problem.</p>
  
  <p>Now, how do I solve the error I am getting? Obviously It is something to do with the fact there are spaces in my DATETIME field. Suggestions please? Thanks.</p>