[wplug] weird php issue

Justin Liebler jliebler at gmail.com
Wed Jan 27 16:09:35 EST 2010


I believe you are getting the correct answer according to ISO 8601.  It
defines the first week of the year as the week with the first Thursday, or
equivalently the first week that contains January 4th.  So that would mean
that this year 1/1/2010 falls in the last week of 2009, week 53.

http://en.wikipedia.org/wiki/ISO_week_date

On Wed, Jan 27, 2010 at 2:24 PM, Chris Romano <romano.chris at gmail.com>wrote:

> On Wed, Jan 27, 2010 at 7:45 AM, Eli Heady <eli.heady at gmail.com> wrote:
> > 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
>
> Well that doesn't work.
>
>
> $firstWeek = gmdate("W",gmmktime(0,0,0,1,1,2010));
> print "First Week = $firstWeek<br>";
>
> prints
>
> First Week = 53
>
> Not sure what's going on now.
>
> Chris
>
> --
> "They that would trade essential liberty for a little temporary safety
> deserve neither." -- Benjamin Franklin
> _______________________________________________
> wplug mailing list
> wplug at wplug.org
> http://www.wplug.org/mailman/listinfo/wplug
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.wplug.org/pipermail/wplug/attachments/20100127/ce7b0d03/attachment.html 


More information about the wplug mailing list