ID: 43739 Updated by: [EMAIL PROTECTED] Reported By: phreaks at gmail dot com -Status: Open +Status: Bogus Bug Type: Date/time related Operating System: Linux PHP Version: 5.2.5 New Comment:
There is no bug here: $fm = 12; $day = 31; echo date("M-d (w)", mktime(1,1,1,$fm,$day)), "\n"; shows correctly: Dec-31 (3) You don;t specify the year to mktime, so it assumes the current one, which is now 2008. Your output is correct for the year 2007. Change your code to this to see it: $fm = 12; $day = 31; for ($i = 0; $i < 7; $i++) echo date("M-d Y (w)", mktime(1,1,1,$fm,$day++))."\n"; Previous Comments: ------------------------------------------------------------------------ [2008-01-03 16:42:05] phreaks at gmail dot com Description: ------------ When adding days to a date returns wrong weekday. This only happens when adding days to 12-31-07. Workaround is handle any new year dates by starting from 1-1-08 and adding days. Reproduce code: --------------- $fm = 12; $day = 31; for ($i = 0; $i < 7; $i++) echo date("M-d (w)", mktime(1,1,1,$fm,$day++))."<BR>"; Expected result: ---------------- Expected output Dec-31 (1) Jan-01 (2) Jan-02 (3) Jan-03 (4) Jan-04 (5) Jan-05 (6) Jan-06 (0) Actual result: -------------- The output of above is: Dec-31 (3) Jan-01 (4) Jan-02 (5) Jan-03 (6) Jan-04 (0) Jan-05 (1) Jan-06 (2) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=43739&edit=1