title: Converting Database date format to yyyy-mm-dd and back to dd-mm-yyyy in PHP
body: <p>Basically I have a date a user selects, that is formatted as follows:</p>
  
  <pre><code>01-12-2013 (dd-mm-yyyy)
  </code></pre>
  
  <p>And I need to format it into a yyyy-mm-dd format for the DB as its a date type like this:</p>
  
  <pre><code>2013-12-01
  </code></pre>
  
  <p>I store my date in a variable, lets call it <code>$date</code></p>
  
  <p>I have tried using the createFromFormat function like this:</p>
  
  <pre><code>$processdate = DateTime::createFromFormat('dd-mm-yy', $date);
  echo $processdate-&gt;format('yy-mm-dd');
  </code></pre>
  
  <p>But I get an error saying that:</p>
  
  <pre><code>Fatal error: Call to a member function format() on a non-object
  </code></pre>
  
  <p>Can someone tell me how I am not using it correctly please?</p>