title: How best to convert CakePHP date picker form data to a PHP DateTime object?
body: <p>I'm doing this in <code>app/views/mymodel/add.ctp</code>:</p>
  
  <pre><code>&lt;?php echo $form-&gt;input('Mymodel.mydatefield'); ?&gt;
  </code></pre>
  
  <p>And then, in <code>app/controllers/mymodel_controller.php</code>:</p>
  
  <pre><code>function add() {
      # ... (if we have some submitted data)
      $datestring = $this-&gt;data['Mymodel']['mydatefield']['year'] . '-' .
                    $this-&gt;data['Mymodel']['mydatefield']['month'] . '-' .
                    $this-&gt;data['Mymodel']['mydatefield']['day'];
      $mydatefield = DateTime::createFromFormat('Y-m-d', $datestring);
  }
  </code></pre>
  
  <p>There absolutly <em>has</em> to be a better way to do this - I just haven't found the CakePHP way yet...</p>
  
  <p>What I would like to do is:</p>
  
  <pre><code>function add() {
      # ... (if we have some submitted data)       
      $mydatefield = $this-&gt;data['Mymodel']['mydatefiled']; # obviously doesn't work
  }
  </code></pre>