note 127508 added to datetimezone.getoffset

From: Date: Wed, 17 Aug 2022 20:13:11 +0000
Subject: note 127508 added to datetimezone.getoffset
Groups: php.notes 
Request: Send a blank email to php-notes+get-219446@lists.php.net to get a copy of this message
Note that the DateTime parameter has no effect in the result returned by DateTimeZone::getOffset($DateTime), unless, it refers to a DateTime where there is daylight savings in the referenced DateTimeZone. Ex.: <?php $timezone_brl = new DateTimeZone('America/Sao_Paulo'); $timezone_eng = new DateTimeZone('Europe/London'); $timezone_aus = new DateTimeZone('Australia/Brisbane'); $dateTimes = [ new DateTime() , new DateTime('now', $timezone_eng) , new DateTime('now', $timezone_aus) , new DateTime('now', $timezone_brl) , new DateTime('2000-06-10', $timezone_brl) , new DateTime('2000-12-10', $timezone_brl) , new DateTime('2020-12-10', $timezone_brl) ]; foreach($dateTimes as $dateTime) { echo "\n" . $timezone_brl->getOffset($dateTime); } /** * -10800 * -10800 * -10800 * -10800 * -10800 // No daylight savings in June/2000 * - 7200 // Brazil had daylight savings until 2020 * -10800 // No more daylight savings, so it returns -10800 */ ?> ---- Server IP: 45.112.84.4 Probable Submitter: 185.85.3.173 (proxied: 2804:14c:5b72:84bb:f812:d107:4918:f972) ---- Manual Page -- https://php.net/manual/en/datetimezone.getoffset.php Edit -- https://main.php.net/note/edit/127508 Del: integrated -- https://main.php.net/note/delete/127508/integrated Del: useless -- https://main.php.net/note/delete/127508/useless Del: bad code -- https://main.php.net/note/delete/127508/bad+code Del: spam -- https://main.php.net/note/delete/127508/spam Del: non-english -- https://main.php.net/note/delete/127508/non-english Del: in docs -- https://main.php.net/note/delete/127508/in+docs Del: other reasons-- https://main.php.net/note/delete/127508 Reject -- https://main.php.net/note/reject/127508 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#219446) next »