ID: 25787 Updated by: [EMAIL PROTECTED] Reported By: australia at bookrealm dot com Status: Bogus Bug Type: Date/time related Operating System: SuSE Linux 8.2 PHP Version: 4.3.1 New Comment:
I meant localtime, not date: # man 3 localtime And look at the tm_yday section. Previous Comments: ------------------------------------------------------------------------ [2003-10-08 06:37:47] [EMAIL PROTECTED] There is no bug and this is how it works in libc provided date() too. ------------------------------------------------------------------------ [2003-10-08 06:27:10] australia at bookrealm dot com Yes, I figured the count started from zero, but really it shouldn't. The 1st of the 1st of any year should be day # 1, not day # 0. The manuals state that 'yday' in getdate() and 'z' in date() give "The day of the year". This is not correct if both are out by one day, and no indication that that is the case, and no indication that you must add one day to make them correct. The proper fix would be to fix the code, but a slacker fix would be to state in the manuals that you must add a day, ie., date("z") + 1, to get the correct "day of the year" number. Up to you, of course, which you choose to do. Cheers, Andrew Skripshak ------------------------------------------------------------------------ [2003-10-08 06:05:45] [EMAIL PROTECTED] Maybe this clears it for you: # php -r 'echo date("z", mktime(1,1,1,1,1,2003));' 0 The count starts from 0.. ------------------------------------------------------------------------ [2003-10-08 05:56:06] australia at bookrealm dot com And, IMHO, the example you gave, echo date("z"); thus also seems to give incorrect results. ------------------------------------------------------------------------ [2003-10-08 05:30:45] australia at bookrealm dot com Month / days (2003) Jan: 31 Feb: 28 Mar: 31 Apr: 30 May: 31 Jun: 30 Jul: 31 Aug: 31 Sep: 30 TOTAL: 273 days Currently 8th of Oct, 2003, thus PLUS 8 days (273 + 8). So today is day: 281 Thus, in my humble opinion, mcal_day_of_year() seem correct, getdate() seems not to be. But, if getdate() is correct, then that makes all the calendars and organizers, paper and computer, incorrect when they state Oct 8, 2003, as being day '281' and not '280'. I did "RTFM" as you had suggested. "0-366" just indicates the number range, correct? Cheers, Andrew Skripshak ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/25787 -- Edit this bug report at http://bugs.php.net/?id=25787&edit=1