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

From: Date: Tue, 25 Nov 2014 06:40:42 +0000
Subject: Bug #68495 [Opn]: Weekday calculated incorrectly using $weekDay = date('N', strtotime($date));
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-188782@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=68495&edit=1 ID: 68495 User updated by: 8f181bd2 at opayq dot com Reported by: 8f181bd2 at opayq dot com -Summary: Exact PHP version +Summary: Weekday calculated incorrectly using $weekDay = date('N', strtotime($date)); Status: Open Type: Bug Package: Date/time related Operating System: Windows PHP Version: 5.5Git-2014-11-25 (Git) Block user comment: N Private report: N New Comment: (edited title) Previous Comments: ------------------------------------------------------------------------ [2014-11-25 06:39:20] 8f181bd2 at opayq dot com Exact PHP version is 5.5.11 (built: Apr 8 2014 15:07:14) ------------------------------------------------------------------------ [2014-11-25 06:25:45] 8f181bd2 at opayq dot com 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 this bug report at https://bugs.php.net/bug.php?id=68495&edit=1

« previous php.bugs (#188782) next »