php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81273 Date interval calculation not correct
Submitted: 2021-07-19 07:23 UTC Modified: 2021-08-08 12:43 UTC
From: alex dot a dot pott at gmail dot com Assigned: derick (profile)
Status: Closed Package: Date/time related
PHP Version: 8.1Git-2021-07-19 (Git) OS: OS X
Private report: No CVE-ID: None
 [2021-07-19 07:23 UTC] alex dot a dot pott at gmail dot com
Description:
------------
Date interval calculation is has changed in 8.1 and the new calculation is incorrect.

8.0: https://3v4l.org/8g4NB#v8.0.8
8.1: https://3v4l.org/8g4NB/rfc#vgit.master

This seems similar to https://bugs.php.net/bug.php?id=80998

Test script:
---------------
<?php

$time = '2000-01-01 00:00:00.000000';
$tz_aus = new DateTimeZone('Australia/Sydney');
$tz_us = new DateTimeZone('America/Los_Angeles');
$auz = new DateTime($time, $tz_aus);
$us = new DateTime($time, $tz_us);

$diff = $auz->diff($us);
// Should output int(19)
var_dump($diff->h);

Expected result:
----------------
It should output:
int(19)

Actual result:
--------------
int(0)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-07-23 10:57 UTC] antonino dot spampinato86 at gmail dot com
Although not related to your problem but to +1 month of php 8.1 (must take the above behavior or change the datetime arithmetic page).

https://3v4l.org/k2gS6
 [2021-08-03 12:42 UTC] ramsey@php.net
-Assigned To: +Assigned To: derick
 [2021-08-04 08:07 UTC] mail at gh01 dot de
This one also: https://bugs.php.net/bug.php?id=81263
 [2021-08-08 11:20 UTC] derick@php.net
@ramsey: none of these are related, only the one by mail at gh01 dot de
 [2021-08-08 12:43 UTC] derick@php.net
-Status: Assigned +Status: Closed
 [2021-08-08 12:43 UTC] derick@php.net
The fix for this bug has been committed.
If you are still experiencing this bug, try to check out latest source from https://github.com/php/php-src and re-test.
Thank you for the report, and for helping us make PHP better.

For 8.1.0beta3
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Nov 28 09:03:14 2021 UTC