How to claculate difference between two dates


I have two variables that store two dates in the format of yyyy-mm-dd.
I need to calculate the duration or difference between the two dates and store it in another variable, so I am using this format to store both dates in PHP

$DeparturedDate = “$year-$month-$day”
$ReturnDate = “$year-$month-$day”

and need something like this:

$Duration = ReturnDate - $DeparturedDate

Any ideas how to achieve this?

Thanks in advance

$duration = strtotime($date1) - strtotime($date2);

Thanks, but it returns a parse error:

Parse error: syntax error, unexpected T_VARIABLE in

I find it utterly fab that your reported parse error contains a truncated parse error!

What was the full message?

Cups: THAT was the error message!!!

Its sorted now, but the calculation always return 0.
not sure what it is?

For PHP 5.3 you could be using: PHP: DateTime::diff - Manual