From: Operating system: Linux (Debian) PHP version: Irrelevant Package: Date/time related Bug Type: Bug Bug description:mktime() changes days when it should't
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 bug report at http://bugs.php.net/bug.php?id=54005&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=54005&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=54005&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=54005&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=54005&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=54005&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=54005&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=54005&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=54005&r=needscript Try newer version: http://bugs.php.net/fix.php?id=54005&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=54005&r=support Expected behavior: http://bugs.php.net/fix.php?id=54005&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=54005&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=54005&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=54005&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=54005&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=54005&r=dst IIS Stability: http://bugs.php.net/fix.php?id=54005&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=54005&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=54005&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=54005&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=54005&r=mysqlcfg