Bug #68195 [Opn->Nab]: Issue with day number / name in a week
| From: | requinix@php.net | Date: | Thu, 09 Oct 2014 08:18:48 +0000 |
| Subject: | Bug #68195 [Opn->Nab]: Issue with day number / name in a week | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-187974@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=68195&edit=1
ID: 68195
Updated by: requinix@php.net
Reported by: sandro dot casa at gmail dot com
Summary: Issue with day number / name in a week
-Status: Open
+Status: Not a bug
Type: Bug
-Package: Calendar related
+Package: Date/time related
Operating System: Windows NT SCA 6.1 build 7601 (W
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Unless you're running one of the experimental builds of PHP x64 for Windows (and probably not
even then), your PHP cannot handle 1900 as a Unix timestamp. It's too far in the past for a
32-bit number.
strtotime() will fail, which means it will return false, which is basically 0, which corresponds to
1970-01-01. Try it:
echo date('r', strtotime($date));
Fortunately, DateTime works differently.
$date = new DateTime('1900-01-01');
echo $date->format('N'); // 1
echo $date->format('l'); // Monday
Previous Comments:
------------------------------------------------------------------------
[2014-10-09 07:55:06] sandro dot casa at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.date
---
l (lowercase 'L'): A full textual representation of the day of the week Sunday through
Saturday
N ISO-8601: numeric representation of the day of the week (added in PHP 5.1.0) 1 (for Monday)
through 7 (for Sunday)
My PHP version is 5.5.6
Test script:
---------------
// My PHP version is 5.5.6
$date = '1900-01-01';
echo date('N', strtotime($date)); // ==> 4
echo date('l', strtotime($date)); // ==> Thurday
The thing is the 1st of Jan 1900 was a Monday...
Expected result:
----------------
$date = '1900-01-01';
echo date('N', strtotime($date)); // ==> 1
echo date('l', strtotime($date)); // ==> Monday
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=68195&edit=1