Bug #78496 [NEW]: date_create rolls a day back on year 0000 timestamp

From: Date: Thu, 05 Sep 2019 15:56:23 +0000
Subject: Bug #78496 [NEW]: date_create rolls a day back on year 0000 timestamp
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-222572@lists.php.net to get a copy of this message
From: dzuczek at dlc-solutions dot com Operating system: Linux PHP version: 7.2.22 Package: Date/time related Bug Type: Bug Bug description:date_create rolls a day back on year 0000 timestamp Description: ------------ date_create seems to roll back a day when given a timestamp in the year 0000 this worked as expected in PHP 7.1, does not work in PHP 7.2 or greater Test script: --------------- Not working (year 0000): https://3v4l.org/manbk Working (year 0001): https://3v4l.org/uMjtB <?php $timestamp = strtotime('0000-02-20 00:00:00 UTC'); // has issues $timestamp2 = strtotime('0001-02-20 00:00:00 UTC'); // this is okay // this has issues print $timestamp . "\n"; $date_time = date_create('@' . $timestamp); print_r($date_time); // this is fine print $timestamp2 . "\n"; $date_time2 = date_create('@' . $timestamp2); print_r($date_time2); ?> Expected result: ---------------- Using 0000-02-20 00:00:00 UTC Expected (PHP 7.1) DateTime Object ( [date] => 0000-02-20 00:00:00.000000 [timezone_type] => 1 [timezone] => +00:00 ) Actual result: -------------- Using 0000-02-20 00:00:00 UTC Actual (PHP 7.2+) DateTime Object ( [date] => 0000-02-19 00:00:00.000000 [timezone_type] => 1 [timezone] => +00:00 ) The resulting date has been rolled back a day. -- Edit bug report at https://bugs.php.net/bug.php?id=78496&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=78496&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=78496&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=78496&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=78496&r=needscript Try newer version: https://bugs.php.net/fix.php?id=78496&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=78496&r=support Expected behavior: https://bugs.php.net/fix.php?id=78496&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=78496&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=78496&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=78496&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=78496&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=78496&r=dst IIS Stability: https://bugs.php.net/fix.php?id=78496&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=78496&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=78496&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=78496&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=78496&r=mysqlcfg

« previous php.bugs (#222572) next »