-2

Possible Duplicate:
How to calculate the difference between two dates using PHP?

I have two dates of the form:

Start Date: 2012-02-10 11:26:00
End Date: 2012-04-25 01:50:00

Now I need to find the difference between these two in the below form:

 years,  months, days, hours, minutes, seconds

How can I do this in PHP?

Community
  • 1
  • 1
keerthi
  • 769
  • 2
  • 9
  • 24

1 Answers1

0

You can use DateTime::diff

$start_date = new DateTime("2012-02-10 11:26:00");
$end_date = new DateTime("2012-04-25 01:50:00");
$interval = $start_date->diff($end_date);
echo "Result " . $interval->y . " years, " . $interval->m." months, ".$interval->d." days ";
vincentLg
  • 325
  • 2
  • 7