Bug #28581 [Com]: mktime bugg
| From: | armahillo at gmail dot com | Date: | Thu, 30 Jun 2016 16:59:25 +0000 |
| Subject: | Bug #28581 [Com]: mktime bugg | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-201949@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=28581&edit=1
ID: 28581
Comment by: armahillo at gmail dot com
Reported by: s_svene at hotmail dot com
Summary: mktime bugg
Status: Not a bug
Type: Bug
Package: Date/time related
Operating System: Windows
PHP Version: 5.0
Block user comment: N
Private report: N
New Comment:
Just verifying that this behavior is still happening in v7.1 (and also 5.5.9, both Ubuntu envs)
How is this not a bug? The default day argument should not cause unintended side effects with the
month.
php > echo date('M', mktime(1,1,1,2));
Mar
php > echo date('M', mktime(1,1,1,3));
Mar
I should not need to do this just to get it to work:
php > echo date('M', mktime(1,1,1,2,1));
Mar
Otherwise why even allow there to be optional arguments in the first place? If I'm omitting the
day, that's implying that the day is irrelevant, so we should be using a default day that
exists in ALL months, not the current day (ie. you could use any of 1-28 and it would be fine)
mktime() should never return a result that invalidates an explicitly provided argument. If
"today's day, but in that month" is the desired default behavior, then an edge case
should be added that traps "this day doesn't exist in that month, so default to day
1".
Previous Comments:
------------------------------------------------------------------------
[2004-06-02 11:03:59] mgf@php.net
When you don't feed mktime() a day, it uses the equivalent value from the current date. The
original post was made on 30th May. Please check the documentation to see what mktime() makes of a
request for 30th Feb.
Definitely not a PHP bug.
------------------------------------------------------------------------
[2004-05-30 20:51:18] pajoye@php.net
Btw, I was silly enough to do not have seen that:
echo(date("m",mktime(0,0,0,3)."<br>");
should be:
echo date("m<b\r>",mktime(0,0,0,3));
If you like to test it, use only mktime or:
date('m', mktime(0,0,0,$m));
Bogus anyway, it works with both php5 and php4.
--Pierre
------------------------------------------------------------------------
[2004-05-30 20:14:29] s_svene at hotmail dot com
I have tried 5.0 to, and i can't get it to work..
going to try 4.6 to but.
------------------------------------------------------------------------
[2004-05-30 19:13:08] pajoye@php.net
Thank you for taking the time to report a problem with PHP.
Unfortunately you are not using a current version of PHP --
the problem might already be fixed. Please download a new
PHP version from http://www.php.net/downloads.php
If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.
Works here with 4.3.6 and snapshots (4 and 5, linux&win32)
--Pierre
------------------------------------------------------------------------
[2004-05-30 17:49:59] s_svene at hotmail dot com
Description:
------------
I have noticed a bug in the commando date("m",mktime(0,0,0,x);
You get the same result if you type in a 2 or a 3 where X belong, that is the nuber of the current
month.
Reproduce code:
---------------
<?php
echo("Month 2 : ");
echo(date("m",mktime(0,0,0,2)."<br>");
echo("Month 3");
echo(date("m",mktime(0,0,0,3)."<br>");
?>
Expected result:
----------------
Month 2 : 2
Month 3 : 3
Actual result:
--------------
Month 2 : 3
Month 3 : 3
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=28581&edit=1