Bug #66980 [Opn->Fbk]: Last day of Fenruary
| From: | ab@php.net | Date: | Wed, 02 Apr 2014 12:07:54 +0000 |
| Subject: | Bug #66980 [Opn->Fbk]: Last day of Fenruary | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-185034@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=66980&edit=1
ID: 66980
Updated by: ab@php.net
Reported by: tm8544 at hotmail dot com
Summary: Last day of Fenruary
-Status: Open
+Status: Feedback
Type: Bug
Package: Date/time related
Operating System: Windows 7
PHP Version: 5.5.10
Block user comment: N
Private report: N
New Comment:
Hi, thanks for reporting. I cannot reproduce it with 5.5.10 or 5.5-dev branch with your snippet.
Both first and last day look correct. Could you please give some more details on how you invoke it,
maybe timezone and so on? To exclude it's a configuration error maybe you could try it on some
other machine.
Thanks.
Previous Comments:
------------------------------------------------------------------------
[2014-03-29 08:43:23] tm8544 at hotmail dot com
As you can see, this problem was produced on 29.3.2014.
I assume that if it was tested on 31.3.2014, also last days of april, june, september and november
would have been wrong.
It is possible to get around this by using
strtotime($string, mktime(0,0,0,date("n"),1)) instead of strtotime($string) in line 6 of
the test script, but my point is that "last day of february" is a known fact for each
year, and the result of the code shall not depend on the date when it is executed.
------------------------------------------------------------------------
[2014-03-29 07:57:48] tm8544 at hotmail dot com
Description:
------------
Code in test script does not correctly produce the last day of february.
Also, if you change the test script to $string = "first day of " . $month;
also the first day of february is wrong (1.3.2014)
For all other months, it works as expected.
Test script:
---------------
<?php
$months = array("january", "february", "march", "april",
"may", "june", "july", "august", "september",
"october", "november", "december");
foreach ($months as $month) {
$string = "last day of " . $month;
echo $month ." - " . date("j.n.Y", strtotime($string)) . "\r\n";
}
?>
Expected result:
----------------
january - 31.1.2014
february - 28.2.2014
march - 31.3.2014
april - 30.4.2014
may - 31.5.2014
june - 30.6.2014
july - 31.7.2014
august - 31.8.2014
september - 30.9.2014
october - 31.10.2014
november - 30.11.2014
december - 31.12.2014
Actual result:
--------------
january - 31.1.2014
february - 31.3.2014
march - 31.3.2014
april - 30.4.2014
may - 31.5.2014
june - 30.6.2014
july - 31.7.2014
august - 31.8.2014
september - 30.9.2014
october - 31.10.2014
november - 30.11.2014
december - 31.12.2014
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=66980&edit=1