因此,我使用此方法獲取了兩個日期之間的差異。將年份或月份轉換爲天數,PHP
$diff = abs(strtotime($date2) - strtotime($date1));
$years = floor($diff/(365*60*60*24));
$months = floor(($diff - $years * 365*60*60*24)/(30*60*60*24));
$days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
現在,讓我們說我想將年份和月份轉換爲天。我怎麼做?
你應該看看這個:http://de2.php.net/DateTime要容易得多。 – looper
重複:http://stackoverflow.com/questions/4233605/elegant-way-to-get-the-count-of-months-between-two-dates – GBD