title: Managing date formats differences between PHP and MySQL
body: <p>I'm writing my first PHP app that has to directly deal with dates, and thus to directly deal with the fact that PHP and MySQL have different date formats.</p>
  
  <p>My question is: what's the most elegant way to manage this difference?</p>
  
  <p>I have the following two functions to manage the difference using php:</p>
  
  <pre><code>function mysql_date($php_date)  {
      return date( 'Y-m-d H:i:s', $php_date );
  }
  
  function php_date($mysql_date) {
      $val = explode(" ",$mysql_date);
      $date = explode("-",$val[0]);
      $time = explode(":",$val[1]);
      return mktime($time[0],$time[1],$time[2],$date[1],$date[2],$date[0]);
  }
  </code></pre>
  
  <p>is there a simpler way to manage this directly within my SQL queries?</p>
  
  <p>Or could you suggest any other more elegant way to manage this?</p>