Bug #72096 [NEW]: Swatch time value incorrect for dates before 1970

From: Date: Sun, 24 Apr 2016 18:54:16 +0000
Subject: Bug #72096 [NEW]: Swatch time value incorrect for dates before 1970
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-200752@lists.php.net to get a copy of this message
From: p987b at davewilliamsmedia dot com Operating system: Windows PHP version: 5.6.20 Package: Date/time related Bug Type: Bug Bug description:Swatch time value incorrect for dates before 1970 Description: ------------ For dates prior to 1970, (i.e. dates represented by a negative unix timestamp value), swatch values produced by the gmdate() function using format character 'B' are incorrectly rounded-up. They consequently differ from the values produced for identical times of day on dates after 1970, as these are correctly rounded-down. This problem occurs on PHP 5.3 as well as 5.6. Test script: --------------- for ($unix=1461283200;$unix<=1461369600;$unix+=8000) { echo "\n Time:".gmdate('Y-m-d H:i:s = B ',$unix); echo " Time:".gmdate('Y-m-d H:i:s = B ',$unix-2592000000); } Expected result: ---------------- I would expect the three-digit swatch time values produced for the 1934 date (right-hand column) to be identical to the swatch values produced for the 2016 date (left-hand column), for any given time of day. Actual result: -------------- Time:2016-04-22 00:00:00 = 041 Time:1934-03-04 00:00:00 = 041 Time:2016-04-22 02:13:20 = 134 Time:1934-03-04 02:13:20 = 135 Time:2016-04-22 04:26:40 = 226 Time:1934-03-04 04:26:40 = 227 Time:2016-04-22 06:40:00 = 319 Time:1934-03-04 06:40:00 = 320 Time:2016-04-22 08:53:20 = 412 Time:1934-03-04 08:53:20 = 413 Time:2016-04-22 11:06:40 = 504 Time:1934-03-04 11:06:40 = 505 Time:2016-04-22 13:20:00 = 597 Time:1934-03-04 13:20:00 = 598 Time:2016-04-22 15:33:20 = 689 Time:1934-03-04 15:33:20 = 690 Time:2016-04-22 17:46:40 = 782 Time:1934-03-04 17:46:40 = 783 Time:2016-04-22 20:00:00 = 875 Time:1934-03-04 20:00:00 = 875 Time:2016-04-22 22:13:20 = 967 Time:1934-03-04 22:13:20 = 968 -- Edit bug report at https://bugs.php.net/bug.php?id=72096&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=72096&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=72096&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=72096&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=72096&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=72096&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=72096&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=72096&r=needscript Try newer version: https://bugs.php.net/fix.php?id=72096&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=72096&r=support Expected behavior: https://bugs.php.net/fix.php?id=72096&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=72096&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=72096&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=72096&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72096&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=72096&r=dst IIS Stability: https://bugs.php.net/fix.php?id=72096&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=72096&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=72096&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=72096&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=72096&r=mysqlcfg

« previous php.bugs (#200752) next »