Posted By

isaac on 04/15/08


Tagged

php date format to usa transform reverse easy d-m-y y-m-d european


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

heinz1959


Easy transform date format d-m-y => y-m-d on PHP


 / Published in: PHP
 

URL: http://www.php.net/manual/es/function.date.php#81946

This changes the date format from d-m-y to y-m-d on PHP. It's easy to change the - to / or spaces...

  1. //This code is extracted from the comments on the php.net docs
  2. // Date: d-m-y => y-m-d
  3.  
  4. $time =explode("-","12-04-2008");
  5. krsort($time);
  6. print "<p>".implode("-",$time)."</p>";
  7.  
  8. //Will return: 2008-04-12.

Report this snippet  

You need to login to post a comment.