I'm a bit stuck with the DateInterval
class of PHP. What I really want is the number of seconds elapsed between two DateTime
stamps.
$t1 = new DateTime( "20100101T1200" );
$t2 = new DateTime( "20100101T1201" );
// number of seconds between t1 and t2 should be 60
echo "difference in seconds: ".$t1->diff($t2)->format("%s");
Yet all I get is zero. Is the DateInterval
class not suited for arithmetic? How can I get the 'exact' number of seconds (or hours, or whatever) between two time stamps?