473,396 Members | 1,877 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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($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?

TIA
Regards
Paul
May 3 '06 #1
6 1349
On Wed, 03 May 2006 11:32:58 +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)

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

May 3 '06 #2
Andy Jeffries wrote:
On Wed, 03 May 2006 11:32:58 +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)

Cheers,
Andy


Nice one. I didn't think of that. Still like to know why the other one was
so wierd.
May 3 '06 #3
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

May 3 '06 #4
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:
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


May 3 '06 #5
Sounds likely. Is this documented anywhere?

er***********@gmail.com wrote:
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:
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


May 3 '06 #6
Paul Lautman wrote:
Sounds likely. Is this documented anywhere?

er***********@gmail.com wrote:
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:

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



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.
js*******@attglobal.net
==================
May 3 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Otto Haldi | last post by:
Hello to all I'm using PHP since a few week. I like to know how php programmers are making so nice border to displaying MySQL table? I like to make a border with rounded corner. Could...
4
by: Dominik | last post by:
I'm looking for some nice-looking DHTML select boxes (combo boxes). Someone knows where can I find it?
0
by: Derek LaZard | last post by:
The ClipBoard Ring in the ToolBox is really a nice feature. Renaming, copying/moving within clipboard, and categorizing is a nice and frequently used feature... :) Derek LaZard
4
by: Reiter Peter | last post by:
hi can someone tell me, how i can create a really nice looking app? with nice effects do i need for this MDX (managed directx), or is it also possible with gdi+? for instance, windows media...
10
by: Justin Dutoit | last post by:
Hey. I'm still not experienced at error handling, and I need to know if Try.. Catch blocks are meant to be used to handle errors in your own app, ie bugs. Or, are they only for external things like...
8
by: Spleenwort | last post by:
With regard to XML comments in c#. I think that #regions should be self-documenting relative to XML comments or that a <region> tag should be defined and auto-inserted when you type #region...
7
by: shapper | last post by:
Hello, Does anyone knows where can I find some nice styled CSS tables? Thanks, Miguel
0
by: Pretty nice site, wants to see much more on it!,Pr | last post by:
Pretty nice site, wants to see much more on it!,Pretty nice site, wants to see much more on it!,Pretty nice site, wants to see much more on it!
3
by: WebCM | last post by:
How to apply nice URL-s into CMS? 1. Should we use nice urls for every page? 2. Do we need to put a FULL path into <a href="">? 3. What is faster and better? a) 10 rules in .htaccess...
3
by: sheldonlg | last post by:
I think this capability is lacking in php. Suppose there is a group of checkboxes all named "procedure". Doing a $_POST returns all the ones that are checked and not the ones that are not...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.