Bug #54005 [Opn->Bgs]: mktime() changes days when it should't
| From: | derick@php.net | Date: | Tue, 15 Feb 2011 21:35:11 +0000 |
| Subject: | Bug #54005 [Opn->Bgs]: mktime() changes days when it should't | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-158801@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=54005&edit=1
ID: 54005
Updated by: derick@php.net
Reported by: taxi at a-city dot de
Summary: mktime() changes days when it should't
-Status: Open
+Status: Bogus
Type: Bug
Package: Date/time related
Operating System: Linux (Debian)
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Sorry, but your problem does not imply a bug in PHP itself. For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system
is not the
appropriate forum for asking support questions. Due to the volume
of reports we can not explain in detail here why your report is not
a bug. The support channels will be able to provide an explanation
for you.
Thank you for your interest in PHP.
I've no idea what you're doing with the 3rd argument to mktime(). You're
passing in Unix timestamps, but with an hour of 1? There is going to be
some DST issues with this at least. Please don't abuse functions like
this.
Previous Comments:
------------------------------------------------------------------------
[2011-02-13 15:47:43] taxi at a-city dot de
Description:
------------
Hi,
I'm trying to use mktime() to calculate when one month is over.
As you can see the day changed at february (which wa fixed by a
quick&dirty-really-bad-hack) and May (more untested).
I think the problem with february is that mktime() doesn't know that
february only has 28 days?
Test script:
---------------
<?
$now = time();
$a = mktime(1, 0, $now, 1, 1, 1970);
$b = mktime(1, 0, $now, 1 + 1, 1, 1970);
$c = mktime(1, 0, $now, 1, 1 + 28, 1970); //28 days couse this month has
only $
$d = mktime(1, 0, $now, 1 + 1, 1 + 28, 1970);
$e = mktime(1, 0, $now, 1 + 2, 1 + 28, 1970);
$f = mktime(1, 0, $now, 1 + 3, 1 + 28, 1970);
$g = mktime(1, 0, $now, 1 + 4, 1 + 28, 1970);
$h = mktime(1, 0, $now, 1 + 5, 1 + 28, 1970);
echo "Now: $now (".date("d.m.Y",$now).")<br>
a: $a (".date("d.m.Y",$a).")<br>
b: $b (".date("d.m.Y",$b).")<br>
c: $c (".date("d.m.Y",$c).")<br>
d: $d (".date("d.m.Y",$d).")<br>
e: $e (".date("d.m.Y",$e).")<br>
f: $f (".date("d.m.Y",$f).")<br>
g: $g (".date("d.m.Y",$g).")<br>
h: $h (".date("d.m.Y",$h).")";
?>
Expected result:
----------------
Now: 1297608181 (13.02.2011)
a: 1297608181 (13.02.2011)
b: 1300286581 (13.03.2011)
c: 1300027381 (10.03.2011)
d: 1302702181 (13.04.2011)
e: 1305121381 (13.05.2011)
f: 1307799781 (13.06.2011)
g: 1310391781 (13.07.2011)
h: 1313070181 (13.08.2011)
Actual result:
--------------
Now: 1297608181 (13.02.2011)
a: 1297608181 (13.02.2011)
b: 1300286581 (16.03.2011)
c: 1300027381 (13.03.2011)
d: 1302702181 (13.04.2011)
e: 1305121381 (11.05.2011)
f: 1307799781 (11.06.2011)
g: 1310391781 (11.07.2011)
h: 1313070181 (11.08.2011)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=54005&edit=1