|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2011-02-15 22:35 UTC] derick@php.net
-Status: Open
+Status: Bogus
[2011-02-15 22:35 UTC] derick@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 01 14:00:02 2025 UTC |
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)