[wplug] weird php issue

Eli Heady eli.heady at gmail.com
Wed Jan 27 07:45:19 EST 2010


On Tue, Jan 26, 2010 at 9:48 PM, Chris Romano <romano.chris at gmail.com> wrote:
> I'm running CentOS and using php 5.1.6
>
> There seems to be an issue with the date function.  I don't know if
> there is something on my end (coding) of it's a system issue.  Here is
> the code in question:
>
> $firstWeek = date("W",mktime(0,0,0,$month,1,$year));
>
> which for January would be something like this
> $firstWeek = date("W",mktime(0,0,0,01,1,2010));
>
> When this code is ran, $firstWeek is being set to 53.  It should be
> set to 01.  The code works perfect if the year is 2009.
>
> Any ideas?
>
> Thanks,
> Chris

Same here: php 5.3.1 (suhosin patched)

Occurs every six years, then in the following year the week is off by -2

A quick search revealed an issue with similar timing, due to daylight
saving time: http://bugs.php.net/bug.php?id=29065

It is suggested in that bug report to use gmmktime or gmdate instead.
Is that an option for you?

date("W",gmdate(0,0,0,01,1,2010));
seems to work as expected

-eli


More information about the wplug mailing list