A nice day out

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

    #1

    A nice day out

    I was trying to use the following formula to add a number of weeks to a
    date, where $b is the number of weeks.
    date('Y-m-d', strtotime($Expi ry_Date)+$b*864 00*7)
    However sometimes it added one day less than it should have done.
    $Expiry_Date was always a Saturday and sometimes the answer was a Saturday
    and sometimes the previous Friday.

    Has anyone any idea why?

    TIA
    Regards
    Paul


  • Andy Jeffries

    #2
    Re: A nice day out

    On Wed, 03 May 2006 11:32:58 +0100, Paul Lautman wrote:
    [color=blue]
    > I was trying to use the following formula to add a number of weeks to a
    > date, where $b is the number of weeks. date('Y-m-d',
    > strtotime($Expi ry_Date)+$b*864 00*7) However sometimes it added one day
    > less than it should have done. $Expiry_Date was always a Saturday and
    > sometimes the answer was a Saturday and sometimes the previous Friday.
    >
    > Has anyone any idea why?[/color]

    No idea, but why not use two strtotime calls:

    strtotime("+$b weeks", strtotime($Expi ry_Date));

    That would be a better native way of handling it (and more readable)

    Cheers,


    Andy


    --
    Andy Jeffries MBCS CITP ZCE | gPHPEdit Lead Developer
    http://www.gphpedit.org | PHP editor for Gnome 2
    http://www.andyjeffries.co.uk | Personal site and photos

    Comment

    • Paul Lautman

      #3
      Re: A nice day out

      Andy Jeffries wrote:[color=blue]
      > On Wed, 03 May 2006 11:32:58 +0100, Paul Lautman wrote:
      >[color=green]
      >> I was trying to use the following formula to add a number of weeks
      >> to a date, where $b is the number of weeks. date('Y-m-d',
      >> strtotime($Expi ry_Date)+$b*864 00*7) However sometimes it added one
      >> day less than it should have done. $Expiry_Date was always a
      >> Saturday and sometimes the answer was a Saturday and sometimes the
      >> previous Friday.
      >>
      >> Has anyone any idea why?[/color]
      >
      > No idea, but why not use two strtotime calls:
      >
      > strtotime("+$b weeks", strtotime($Expi ry_Date));
      >
      > That would be a better native way of handling it (and more readable)
      >
      > Cheers,
      >
      >
      > Andy[/color]

      Nice one. I didn't think of that. Still like to know why the other one was
      so wierd.


      Comment

      • Andy Jeffries

        #4
        Re: A nice day out

        On Wed, 03 May 2006 13:05:25 +0100, Paul Lautman wrote:[color=blue][color=green][color=darkred]
        >>> I was trying to use the following formula to add a number of weeks to a
        >>> date, where $b is the number of weeks. date('Y-m-d',
        >>> strtotime($Expi ry_Date)+$b*864 00*7) However sometimes it added one day
        >>> less than it should have done. $Expiry_Date was always a Saturday and
        >>> sometimes the answer was a Saturday and sometimes the previous Friday.
        >>>
        >>> Has anyone any idea why?[/color]
        >>
        >> No idea, but why not use two strtotime calls:
        >>
        >> strtotime("+$b weeks", strtotime($Expi ry_Date));
        >>
        >> That would be a better native way of handling it (and more readable)[/color]
        >
        > Nice one. I didn't think of that. Still like to know why the other one was
        > so wierd.[/color]

        No idea.... I tend not to get hung up on problems when I've found a
        solution though, life's too short ;-)

        Cheers,


        Andy


        --
        Andy Jeffries MBCS CITP ZCE | gPHPEdit Lead Developer
        http://www.gphpedit.org | PHP editor for Gnome 2
        http://www.andyjeffries.co.uk | Personal site and photos

        Comment

        • erik.f.boberg@gmail.com

          #5
          Re: A nice day out

          It is probably due to one day every year being 25 hours in php. its a
          day in october i think and the reason is related to daylight savings
          time i think. I had the same problem while making a calendar for my
          homepage a while ago.

          Andy Jeffries skrev:
          [color=blue]
          > On Wed, 03 May 2006 13:05:25 +0100, Paul Lautman wrote:[color=green][color=darkred]
          > >>> I was trying to use the following formula to add a number of weeks to a
          > >>> date, where $b is the number of weeks. date('Y-m-d',
          > >>> strtotime($Expi ry_Date)+$b*864 00*7) However sometimes it added one day
          > >>> less than it should have done. $Expiry_Date was always a Saturday and
          > >>> sometimes the answer was a Saturday and sometimes the previous Friday.
          > >>>
          > >>> Has anyone any idea why?
          > >>
          > >> No idea, but why not use two strtotime calls:
          > >>
          > >> strtotime("+$b weeks", strtotime($Expi ry_Date));
          > >>
          > >> That would be a better native way of handling it (and more readable)[/color]
          > >
          > > Nice one. I didn't think of that. Still like to know why the other one was
          > > so wierd.[/color]
          >
          > No idea.... I tend not to get hung up on problems when I've found a
          > solution though, life's too short ;-)
          >
          > Cheers,
          >
          >
          > Andy
          >
          >
          > --
          > Andy Jeffries MBCS CITP ZCE | gPHPEdit Lead Developer
          > http://www.gphpedit.org | PHP editor for Gnome 2
          > http://www.andyjeffries.co.uk | Personal site and photos[/color]

          Comment

          • Paul Lautman

            #6
            Re: A nice day out

            Sounds likely. Is this documented anywhere?

            erik.f.boberg@g mail.com wrote:[color=blue]
            > It is probably due to one day every year being 25 hours in php. its a
            > day in october i think and the reason is related to daylight savings
            > time i think. I had the same problem while making a calendar for my
            > homepage a while ago.
            >
            > Andy Jeffries skrev:
            >[color=green]
            >> On Wed, 03 May 2006 13:05:25 +0100, Paul Lautman wrote:[color=darkred]
            >>>>> I was trying to use the following formula to add a number of
            >>>>> weeks to a date, where $b is the number of weeks. date('Y-m-d',
            >>>>> strtotime($Expi ry_Date)+$b*864 00*7) However sometimes it added
            >>>>> one day less than it should have done. $Expiry_Date was always a
            >>>>> Saturday and sometimes the answer was a Saturday and sometimes
            >>>>> the previous Friday.
            >>>>>
            >>>>> Has anyone any idea why?
            >>>>
            >>>> No idea, but why not use two strtotime calls:
            >>>>
            >>>> strtotime("+$b weeks", strtotime($Expi ry_Date));
            >>>>
            >>>> That would be a better native way of handling it (and more
            >>>> readable)
            >>>
            >>> Nice one. I didn't think of that. Still like to know why the other
            >>> one was so wierd.[/color]
            >>
            >> No idea.... I tend not to get hung up on problems when I've found a
            >> solution though, life's too short ;-)
            >>
            >> Cheers,
            >>
            >>
            >> Andy
            >>
            >>
            >> --
            >> Andy Jeffries MBCS CITP ZCE | gPHPEdit Lead Developer
            >> http://www.gphpedit.org | PHP editor for Gnome 2
            >> http://www.andyjeffries.co.uk | Personal site and photos[/color][/color]



            Comment

            • Jerry Stuckle

              #7
              Re: A nice day out

              Paul Lautman wrote:[color=blue]
              > Sounds likely. Is this documented anywhere?
              >
              > erik.f.boberg@g mail.com wrote:
              >[color=green]
              >>It is probably due to one day every year being 25 hours in php. its a
              >>day in october i think and the reason is related to daylight savings
              >>time i think. I had the same problem while making a calendar for my
              >>homepage a while ago.
              >>
              >>Andy Jeffries skrev:
              >>
              >>[color=darkred]
              >>>On Wed, 03 May 2006 13:05:25 +0100, Paul Lautman wrote:
              >>>
              >>>>>>I was trying to use the following formula to add a number of
              >>>>>>weeks to a date, where $b is the number of weeks. date('Y-m-d',
              >>>>>>strtotime ($Expiry_Date)+ $b*86400*7) However sometimes it added
              >>>>>>one day less than it should have done. $Expiry_Date was always a
              >>>>>>Saturda y and sometimes the answer was a Saturday and sometimes
              >>>>>>the previous Friday.
              >>>>>>
              >>>>>>Has anyone any idea why?
              >>>>>
              >>>>>No idea, but why not use two strtotime calls:
              >>>>>
              >>>>>strtotime( "+$b weeks", strtotime($Expi ry_Date));
              >>>>>
              >>>>>That would be a better native way of handling it (and more
              >>>>>readable )
              >>>>
              >>>>Nice one. I didn't think of that. Still like to know why the other
              >>>>one was so wierd.
              >>>
              >>>No idea.... I tend not to get hung up on problems when I've found a
              >>>solution though, life's too short ;-)
              >>>
              >>>Cheers,
              >>>
              >>>
              >>>Andy
              >>>
              >>>
              >>>--
              >>>Andy Jeffries MBCS CITP ZCE | gPHPEdit Lead Developer
              >>>http://www.gphpedit.org | PHP editor for Gnome 2
              >>>http://www.andyjeffries.co.uk | Personal site and photos[/color][/color]
              >
              >
              >
              >[/color]

              Yep, it's called Daylight Savings Time in the United States. Last Sunday in
              October at 2AM clocks are set back to 1AM.

              --
              =============== ===
              Remove the "x" from my email address
              Jerry Stuckle
              JDS Computer Training Corp.
              jstucklex@attgl obal.net
              =============== ===

              Comment

              Working...