note 120108 added to datetime.diff

From: Date: Wed, 02 Nov 2016 02:09:48 +0000
Subject: note 120108 added to datetime.diff
Groups: php.notes 
Request: Send a blank email to php-notes+get-207003@lists.php.net to get a copy of this message
Be careful, the behaviour depends on the time zones in a weird way. <?php 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 different: Year: 00 Month: 01 Day: 00 Year: 00 Month: 00 Day: 30 ---- Server IP: 72.52.91.14 Probable Submitter: 202.134.232.22 ---- Manual Page -- http://php.net/manual/en/datetime.diff.php Edit -- https://master.php.net/note/edit/120108 Del: integrated -- https://master.php.net/note/delete/120108/integrated Del: useless -- https://master.php.net/note/delete/120108/useless Del: bad code -- https://master.php.net/note/delete/120108/bad+code Del: spam -- https://master.php.net/note/delete/120108/spam Del: non-english -- https://master.php.net/note/delete/120108/non-english Del: in docs -- https://master.php.net/note/delete/120108/in+docs Del: other reasons-- https://master.php.net/note/delete/120108 Reject -- https://master.php.net/note/reject/120108 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#207003) next »