title: Enabling microseconds in Symfony2 (Doctrine) and MySQL
body: <p>I have an entity with one column of "datetime" type to store a timestamp.</p>
  
  <blockquote>
  <pre><code>/**
   * @ORM\Column(type="datetime")
   */
  protected $timestamp;
  </code></pre>
  </blockquote>
  
  <p>I had MySQL 5.5.40 and I discovered it does not store microseconds. So I switched to 5.6.21 and imported all my tables and data.</p>
  
  <p>I tried to declare the type as </p>
  
  <blockquote>
  <pre><code> * @ORM\Column(type="datetime(6)")
  </code></pre>
  </blockquote>
  
  <p>but it gave me an error. So I changed it directly in the DB by doing:</p>
  
  <blockquote>
  <pre><code>ALTER TABLE symfony.hrmgmt MODIFY timestamp DATETIME(6);
  </code></pre>
  </blockquote>
  
  <p>In my controller I do this:</p>
  
  <blockquote>
  <pre><code>  $dt = new \DateTime('now');
    $newHREvent-&gt;setTimestamp($dt);
  </code></pre>
  </blockquote>
  
  <p>But nonetheless the timestamp is stored without fractions of second.</p>
  
  <p>I can (now) manually enter datetime with fractional values via SQL, but when I do it through my controller it always stores with .000000</p>
  
  <p>I suppose that's because Doctrine does not know that it can store also microseconds.</p>
  
  <p>My PHP version is still 5.4.34.</p>
  
  <p>Thank you!</p>