fork download
  1. <?php
  2.  
  3. // entrada com MÊS / DIA / ANO
  4. $date1 = DateTime::createFromFormat('m/d/Y', '11/12/2014');
  5.  
  6. echo $date1->format('Y-m-d').PHP_EOL; // Output: 2014-11-12
  7.  
  8. // entrada com DIA / MÊS / ANO
  9. $date2 = DateTime::createFromFormat('d/m/Y', '31/10/2014');
  10. echo $date2->format('Y-m-d').PHP_EOL; // Output: 2014-10-31
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
2014-11-12
2014-10-31