PHP - MySQL Date Conversion


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. // From MySQL (YYYY-MM-DD) to European (DD/MM/YYYY)
  2. $mysql_date = '2011-12-26';
  3. $euro_date = date('d/m/Y', strtotime($mysql_date));
  4.  
  5. // From European (DD/MM/YYYY) to MySQL (YYYY-MM-DD)
  6. $euro_date = '26/12/2011';
  7. list($d,$m,$y) = explode('/',$euro_date);
  8. $mysql_date = "$y-$m-$d";

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.