note 128043 added to datetime.diff

From: Date: Fri, 23 Dec 2022 03:33:49 +0000
Subject: note 128043 added to datetime.diff
Groups: php.notes 
Request: Send a blank email to php-notes+get-219999@lists.php.net to get a copy of this message
Please be aware that diff functions (like the entire TimeDate extension) don't support leap seconds. For instance: $origin = new DateTime('2016-12-31T23:59:59', new DateTimeZone('UTC') ); $target = new DateTime('2017-01-01T00:00:00', new DateTimeZone('UTC') ); $interval = $origin->diff($target); echo $interval->format('%s secs'); says '1 secs' and there were 2 seconds in fact, because there was an extra 1 second added after 2016-12-31 23:59:59. Yes indeed, the time 2016-12-31 23:59:60 is correct and between 2016-12-31 23:59:60 and 2017-01-01 00:00:00 there was 1 second! ---- Server IP: 45.112.84.4 Probable Submitter: 185.85.3.54 (proxied: 85.221.144.190) ---- Manual Page -- https://php.net/manual/en/datetime.diff.php Edit -- https://main.php.net/note/edit/128043 Del: integrated -- https://main.php.net/note/delete/128043/integrated Del: useless -- https://main.php.net/note/delete/128043/useless Del: bad code -- https://main.php.net/note/delete/128043/bad+code Del: spam -- https://main.php.net/note/delete/128043/spam Del: non-english -- https://main.php.net/note/delete/128043/non-english Del: in docs -- https://main.php.net/note/delete/128043/in+docs Del: other reasons-- https://main.php.net/note/delete/128043 Reject -- https://main.php.net/note/reject/128043 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#219999) next »