Bug #78452 [NEW]: diff makes worng in hour
| From: | hamedzarei dot 7232 at gmail dot com | Date: | Sat, 24 Aug 2019 17:20:51 +0000 |
| Subject: | Bug #78452 [NEW]: diff makes worng in hour | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-222392@lists.php.net to get a copy of this message | ||
From: hamedzarei dot 7232 at gmail dot com
Operating system: linux
PHP version: 7.4.0beta4
Package: Date/time related
Bug Type: Bug
Bug description:diff makes worng in hour
Description:
------------
Diff between 2 DateTimes makes wrong in hour and create -1
I test some cases and think is about setting timezone
Test script:
---------------
date_default_timezone_set('Asia/Tehran');
$date1 = new \DateTime('2019-09-24 11:47:24');
$date2 = new \DateTime('2019-08-21 12:47:24');
var_dump($date1->diff($date2));
Expected result:
----------------
object(DateInterval)#3 (16) {
["y"]=>
int(0)
["m"]=>
int(1)
["d"]=>
int(2)
["h"]=>
int(23)
["i"]=>
int(0)
["s"]=>
int(0)
["f"]=>
float(0)
["weekday"]=>
int(0)
["weekday_behavior"]=>
int(0)
["first_last_day_of"]=>
int(0)
["invert"]=>
int(1)
["days"]=>
int(33)
["special_type"]=>
int(0)
["special_amount"]=>
int(0)
["have_weekday_relative"]=>
int(0)
["have_special_relative"]=>
int(0)
}
Actual result:
--------------
object(DateInterval)#3 (16) {
["y"]=>
int(0)
["m"]=>
int(1)
["d"]=>
int(3)
["h"]=>
int(-1)
["i"]=>
int(0)
["s"]=>
int(0)
["f"]=>
float(0)
["weekday"]=>
int(0)
["weekday_behavior"]=>
int(0)
["first_last_day_of"]=>
int(0)
["invert"]=>
int(1)
["days"]=>
int(33)
["special_type"]=>
int(0)
["special_amount"]=>
int(0)
["have_weekday_relative"]=>
int(0)
["have_special_relative"]=>
int(0)
}
--
Edit bug report at https://bugs.php.net/bug.php?id=78452&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=78452&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=78452&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=78452&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=78452&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=78452&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=78452&r=support
Expected behavior: https://bugs.php.net/fix.php?id=78452&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=78452&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=78452&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=78452&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=78452&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=78452&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=78452&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=78452&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=78452&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=78452&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=78452&r=mysqlcfg