fork download
  1. <?php
  2. /** solution 1 */
  3. $date1 = "1900-00-00";
  4. $date2 = "2000-00-00";
  5.  
  6. $dt1 = new DateTime($date1);
  7. $dt2 = new DateTime($date2);
  8.  
  9. $diff = $dt1->diff($dt2);
  10. printf("%d years, %d months, %d days", $diff->y, $diff->m, $diff->d);
  11.  
  12. /** solution 2 */
  13. $diff = date_diff(new DateTime("1900-00-00"), new DateTime("2000-00-00"));
  14. printf("%d years, %d months, %d days", $diff->y, $diff->m, $diff->d);
Success #stdin #stdout 0.02s 23888KB
stdin
Standard input is empty
stdout
100 years, 0 months, 0 days100 years, 0 months, 0 days