PHP Obtaining Difference Between Two Dates – String Function

<?php
  $date1 = '14 Jun 2002';
  $date2 = '05 Feb 2006';  $ts1 = strtotime($date1);
  $ts2 = strtotime($date2);  printf("<p>The difference between %s and %s is %d seconds.<p>\n",
          $date1, $date2, $ts2 - $ts1);
?>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.