Why does php datetime diff depend on time zones?
问题 See the following code: function printDiff($tz) { $d1 = new DateTime("2015-06-01", new DateTimeZone($tz)); $d2 = new DateTime("2015-07-01", new DateTimeZone($tz)); $diff = $d1->diff($d2); print($diff->format("Year: %Y Month: %M Day: %D"). PHP_EOL); } printDiff("UTC"); printDiff("Australia/Melbourne"); The result is: Year: 00 Month: 01 Day: 00 Year: 00 Month: 00 Day: 30 Questions: How can the difference between the same day of two adjacent months (1st of June and July) be different than 1