Strange Dec 1969 Bug with date

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • will

    #1

    Strange Dec 1969 Bug with date

    The following piece of code should iterate through the months printing
    out the months and years combined. However date seems to have a
    preference for December 1969 after February 2004 (which of course, we
    all know, should be March 2004). After it prints 1969 it will happily
    print April 2004 as though nothing happened:

    $td = date("j");
    $tm = date("MY");
    # MonthsYears
    for ( $i = 0; $i <=6 ;$i ++){
    $theday = mktime(0,0,0,da te("m")+$i ,date("d") ,date("Y"));
    $option =date("M y", $theday ); // Set how it will look.
    echo "$option<br >";

    }

    this will print out
    Oct 03
    Nov 03
    Dec 03
    Jan 04
    Feb 04
    Dec 69
    Apr 04

    which errr isnt right.

    Any ideas gratfully recevied. This cant be the first time!
    PHP Version 4.3.3
    will
  • Tom Thackrey

    #2
    Re: Strange Dec 1969 Bug with date


    On 28-Oct-2003, spam@sourceymon key.com (will) wrote:
    [color=blue]
    > The following piece of code should iterate through the months printing
    > out the months and years combined. However date seems to have a
    > preference for December 1969 after February 2004 (which of course, we
    > all know, should be March 2004). After it prints 1969 it will happily
    > print April 2004 as though nothing happened:
    >
    > $td = date("j");
    > $tm = date("MY");
    > # MonthsYears
    > for ( $i = 0; $i <=6 ;$i ++){
    > $theday = mktime(0,0,0,da te("m")+$i ,date("d") ,date("Y"));
    > $option =date("M y", $theday ); // Set how it will look.
    > echo "$option<br >";
    >
    > }
    >
    > this will print out
    > Oct 03
    > Nov 03
    > Dec 03
    > Jan 04
    > Feb 04
    > Dec 69
    > Apr 04
    >
    > which errr isnt right.
    >
    > Any ideas gratfully recevied. This cant be the first time!
    > PHP Version 4.3.3[/color]

    The code you posted works fine for me (e.g. it displayed Mar 04).

    Why don't you echo the values of $theday and $i to see which is getting
    screwed up?

    --
    Tom Thackrey

    tom (at) creative (dash) light (dot) com
    do NOT send email to jamesbutler@wil lglen.net (it's reserved for spammers)

    Comment

    • will

      #3
      Re: Strange Dec 1969 Bug with date

      "Tom Thackrey" <use.signature@ nospam.com> wrote in message news:<vWvnb.83$ Gq3.26@newssvr1 4.news.prodigy. com>...[color=blue]
      > On 28-Oct-2003, spam@sourceymon key.com (will) wrote:
      >[color=green]
      > > The following piece of code should iterate through the months printing
      > > out the months and years combined. However date seems to have a
      > > preference for December 1969 after February 2004 (which of course, we
      > > all know, should be March 2004). After it prints 1969 it will happily
      > > print April 2004 as though nothing happened:
      > >
      > > $td = date("j");
      > > $tm = date("MY");
      > > # MonthsYears
      > > for ( $i = 0; $i <=6 ;$i ++){
      > > $theday = mktime(0,0,0,da te("m")+$i ,date("d") ,date("Y"));
      > > $option =date("M y", $theday ); // Set how it will look.
      > > echo "$option<br >";
      > >
      > > }
      > >
      > > this will print out
      > > Oct 03
      > > Nov 03
      > > Dec 03
      > > Jan 04
      > > Feb 04
      > > Dec 69
      > > Apr 04
      > >
      > > which errr isnt right.
      > >
      > > Any ideas gratfully recevied. This cant be the first time!
      > > PHP Version 4.3.3[/color]
      >
      > The code you posted works fine for me (e.g. it displayed Mar 04).
      >
      > Why don't you echo the values of $theday and $i to see which is getting
      > screwed up?[/color]

      Nope I think its a Mac Bug. Hell knows why.. works fine on linux and
      windows php builds
      Ive fixed it by a bodge for now.

      :(

      w

      Comment

      Working...