|
Posted by Andy Jeffries on 05/03/06 15:07
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 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($Expiry_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
[Back to original message]
|