Bug #68495 [NEW]: Weekday calculated incorrectly using $weekDay = date('N', strtotime($date));

From: Date: Tue, 25 Nov 2014 06:25:45 +0000
Subject: Bug #68495 [NEW]: Weekday calculated incorrectly using $weekDay = date('N', strtotime($date));
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-188780@lists.php.net to get a copy of this message
From: chanceofwonder at gmx dot com Operating system: Windows PHP version: 5.5Git-2014-11-25 (Git) Package: Date/time related Bug Type: Bug Bug description:Weekday calculated incorrectly using $weekDay = date('N', strtotime($date)); Description: ------------ Weekday calculated incorrectly for dates in the far future, using $weekDay = date('N', strtotime($date)); Test script: --------------- function getWeekday($date) { $dateTime = \DateTime::createFromFormat('m/d/Y', $date); $date = date_format($dateTime, 'm/d/Y'); $weekDay = date('N', strtotime($date)); return $weekDay; } $arr = ['01/04/2050' => 'Sun', '01/09/2050' => 'Tues', '07/04/2050' => 'Mon', '04/06/2014' => 'Sun', '10/22/2014' => 'Wed', '10/25/2014' => 'Sat', '11/23/2014' => 'Sun']; foreach($arr as $date => $shouldBe) { echo $date.' is on weekday '.getWeekday($date).' - This should be '.$shouldBe.'<br/>'; } Expected result: ---------------- 01/04/2050 is on weekday 0 - This should be Sun 01/09/2050 is on weekday 2 - This should be Tues 07/04/2050 is on weekday 1 - This should be Mon 04/06/2014 is on weekday 7 - This should be Sun 10/22/2014 is on weekday 3 - This should be Wed 10/25/2014 is on weekday 6 - This should be Sat 11/23/2014 is on weekday 7 - This should be Sun Actual result: -------------- 01/04/2050 is on weekday 4 - This should be Sun 01/09/2050 is on weekday 4 - This should be Tues 07/04/2050 is on weekday 4 - This should be Mon 04/06/2014 is on weekday 7 - This should be Sun 10/22/2014 is on weekday 3 - This should be Wed 10/25/2014 is on weekday 6 - This should be Sat 11/23/2014 is on weekday 7 - This should be Sun -- Edit bug report at https://bugs.php.net/bug.php?id=68495&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=68495&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=68495&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=68495&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=68495&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=68495&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=68495&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=68495&r=needscript Try newer version: https://bugs.php.net/fix.php?id=68495&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=68495&r=support Expected behavior: https://bugs.php.net/fix.php?id=68495&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=68495&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=68495&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=68495&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=68495&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=68495&r=dst IIS Stability: https://bugs.php.net/fix.php?id=68495&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=68495&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=68495&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=68495&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=68495&r=mysqlcfg

« previous php.bugs (#188780) next »