Edit report at https://bugs.php.net/bug.php?id=61599&edit=1

 ID:                 61599
 Comment by:         paul at paul-robinson dot us
 Reported by:        grom358_spamkill at yahoo dot com dot au
 Summary:            Wrong Day of Week
 Status:             Open
 Type:               Bug
 Package:            Date/time related
 Operating System:   Linux
 PHP Version:        5.3.10
 Block user comment: N
 Private report:     N

 New Comment:

This was reported (in error) to Wikimedia for their Wikipedia software, the bug 
number is 48907:

https://bugzilla.wikimedia.org/show_bug.cgi?id=48907


Previous Comments:
------------------------------------------------------------------------
[2013-05-28 19:47:06] paul at paul-robinson dot us

I can confirm this bug, which I originally thought was in Wikimedia.

<?php
 $h = mktime(0, 0, 0, 1, 1, 1600);
 $d = date("F dS, Y", $h) ;
 $w= date("l", $h) ;
 Echo "$d is on a $w<br>";
 $h = mktime(0, 0, 0, 1, 1, 1599);
 $d = date("F dS, Y", $h) ;
 $w= date("l", $h) ;
 Echo "$d is on a $w<br>";
 ?>

Returns:

January 01st, 1600 is on a Saturday
January 01st, 1599 is on a Saturday


January 1, 1599 was a Friday.

I did a few other tests for Wikimedia, you can see how they show up there.

http://en.wikipedia.org/w/index.php?title=Template:X8&oldid=557212409

Another version:

<?php
 $h = mktime(0, 0, 0, 5, 28, 2013);
 $d = date("F dS, Y", $h) ;
 $w= date("l", $h) ;
 Echo "$d is on a $w, ";
 $h = mktime(0, 0, 0, 1, 1, 2013);
 $d = date("F dS, Y", $h) ;
 $w= date("l", $h) ;
 Echo "$d is on a $w, ";
 $h = mktime(0, 0, 0, 1, 1, 1901);
 $d = date("F dS, Y", $h) ;
 $w= date("l", $h) ;
 Echo "$d is on a $w, ";
 $h = mktime(0, 0, 0, 1, 1, 1900);
 $d = date("F dS, Y", $h) ;
 $w= date("l", $h) ;
 Echo "$d is on a $w, ";
 $h = mktime(0, 0, 0, 1, 1, 1601);
 $d = date("F dS, Y", $h) ;
 $w= date("l", $h) ;
 Echo "$d is on a $w, ";
 $h = mktime(0, 0, 0, 1, 1, 1600);
 $d = date("F dS, Y", $h) ;
 $w= date("l", $h) ;
 Echo "$d is on a $w<br>";
 $h = mktime(0, 0, 0, 1, 1, 1599);
 $d = date("F dS, Y", $h) ;
 $w= date("l", $h) ;
 Echo "$d is on a $w, ";
 $h = mktime(0, 0, 0, 1, 1, 1598);
 $d = date("F dS, Y", $h) ;
 $w= date("l", $h) ;
 Echo "$d is on a $w<br>";

 ?>

Results:
May 28th, 2013 is on a Tuesday, January 01st, 2013 is on a Tuesday, January 
01st, 1901 is on a Tuesday, January 01st, 1900 is on a Monday, January 01st, 
1601 is on a Monday, January 01st, 1600 is on a Saturday
January 01st, 1599 is on a Saturday, January 01st, 1598 is on a Friday

Today, 2013, 1901, 1900, 1601 and 1600 are correct.
1599 and 1598 are incorrect. 1599 was a Friday, 1598 was a Thursday.

------------------------------------------------------------------------
[2012-05-13 22:29:02] grom358_spamkill at yahoo dot com dot au

Just to make it clearer, run the following:
<?php
$date = new DateTime();
$date->setDate(1599, 12, 31);
echo $date->format('l, jS F Y') . PHP_EOL;
$date->setDate(1600, 1, 1);
echo $date->format('l, jS F Y') . PHP_EOL;

You will see there is two saturdays in a row :O

------------------------------------------------------------------------
[2012-05-12 23:57:26] grom358_spamkill at yahoo dot com dot au

@zhanglijiu it should return Friday so your results confirm this bug

------------------------------------------------------------------------
[2012-05-11 15:54:22] zhanglijiu at gmail dot com

According to your code,my results is "Saturday, 15th October 1582 Saturday, 
31st 
December 1599", there is nothing wrong.

My system is Mac 10.6.8 PHP 5.3.1

------------------------------------------------------------------------
[2012-04-02 06:08:04] grom358_spamkill at yahoo dot com dot au

Description:
------------
The 15th October 1582 is a Friday (see 
http://en.wikipedia.org/wiki/Gregorian_calendar). Testing with Python and Java 
confirms this as well. Also checked the Gnome calendar.

The Proleptic Gregorian Calendar (see 
http://en.wikipedia.org/wiki/Proleptic_Gregorian_calendar) just extends the 
Gregorian calendar backwards. I'm assuming PHP is using proleptic calendar, 
which 
would make 4th october 1582 a monday. But again DateTime gets it wrong.

I made a script to find the breaking point, and it occurs at 31st December 
1599. 
It returns it as a Saturday when in fact its a Friday.



Test script:
---------------
<?php
$date = new DateTime();
$date->setDate(1582, 10, 15);
echo $date->format('l, jS F Y') . PHP_EOL;

$date->setDate(1599, 12, 31);
echo $date->format('l, jS F Y') . PHP_EOL;

Expected result:
----------------
Friday, 15th October 1582
Friday, 31st December 1599

Actual result:
--------------
Saturday, 15th October 1582
Saturday, 31st December 1599


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=61599&edit=1

Reply via email to