我有點卡在PHP的DateInterval
類。我真正想要的是兩張DateTime
郵票之間經過的秒數。php:日期時間算術
$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");
然而,我所得到的是零。 DateInterval
類不適合算術嗎?如何可以我得到兩個時間戳之間的「確切」秒數(或小時,或其他)?
我想看看你如何得到確切的數字超過幾天。 – 2010-06-20 11:56:07