fork download
  1. <?php
  2.  
  3. $data1 = new DateTime("2017-05-12");
  4. $data2 = new DateTime("2017-05-09");
  5.  
  6. $diff = $data1->diff($data2);
  7.  
  8. echo $diff->format("Diferença de %y anos, %m meses e %d dias."), PHP_EOL;
Success #stdin #stdout 0.01s 83904KB
stdin
Standard input is empty
stdout
Diferença de 0 anos, 0 meses e 3 dias.