Edit report at http://bugs.php.net/bug.php?id=27789&edit=1
ID: 27789 Updated by: der...@php.net Reported by: summercom at comcast dot net Summary: march returned instead of february with mktime and date Status: Bogus Type: Bug Package: Date/time related Operating System: Windows XP SP1 PHP Version: 4.3.5 New Comment: john, It's not a bug and it *has* been "fixed": http://derickrethans.nl/obtaining-the-next-month-in-php.html Previous Comments: ------------------------------------------------------------------------ [2010-03-29 18:52:10] john at rfnsoftware dot com $mydate->modify("-1 month") yields same month when current date is March 29-31, since February is 28 or 29 days. So if this was reported in 2004, should not it be corrected yet? Is it programmers responsibility to check - if subracting one month does not change the month then do it again? I don't call that clutter. I don't have time to search for bug reports all of the time. This one should get fixed ASAP. ------------------------------------------------------------------------ [2004-03-30 22:00:05] poll...@php.net Today is the 30th. When using mktime with only four parameters as you are you'll get the hour, minute, second, and month specified for the current day and year. February 30th, because it doesn't actually exist, translates out to March 2nd. Please search the bug database next time. This has been reported and explained several times already. ------------------------------------------------------------------------ [2004-03-30 21:19:06] summercom at comcast dot net Description: ------------ When using mktime and the date functions it seems that instead of properly returning "February" the two functions used together will return "March" Reproduce code: --------------- <?php $i = 1; do { echo "date(\"F\", mktime(0, 0, 0, $i)); --> ".date("F", mktime(0, 0, 0, $i))."<br />\n"; $i++; } while ($i < 13); ?> Expected result: ---------------- date("F", mktime(0, 0, 0, 1)); --> January date("F", mktime(0, 0, 0, 2)); --> February date("F", mktime(0, 0, 0, 3)); --> March date("F", mktime(0, 0, 0, 4)); --> April date("F", mktime(0, 0, 0, 5)); --> May date("F", mktime(0, 0, 0, 6)); --> June date("F", mktime(0, 0, 0, 7)); --> July date("F", mktime(0, 0, 0, 8)); --> August date("F", mktime(0, 0, 0, 9)); --> September date("F", mktime(0, 0, 0, 10)); --> October date("F", mktime(0, 0, 0, 11)); --> November date("F", mktime(0, 0, 0, 12)); --> December Actual result: -------------- date("F", mktime(0, 0, 0, 1)); --> January date("F", mktime(0, 0, 0, 2)); --> March date("F", mktime(0, 0, 0, 3)); --> March date("F", mktime(0, 0, 0, 4)); --> April date("F", mktime(0, 0, 0, 5)); --> May date("F", mktime(0, 0, 0, 6)); --> June date("F", mktime(0, 0, 0, 7)); --> July date("F", mktime(0, 0, 0, 8)); --> August date("F", mktime(0, 0, 0, 9)); --> September date("F", mktime(0, 0, 0, 10)); --> October date("F", mktime(0, 0, 0, 11)); --> November date("F", mktime(0, 0, 0, 12)); --> December ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=27789&edit=1