RE: [PHP] strange behaviour with strtotime()

2006-01-31 Thread Ford, Mike
On 31 January 2006 15:41, Barry wrote:

> Ford, Mike wrote:
> > Yes, but 1 apple is 1 apple is 1 apple.
> > 
> > 1 month can be 28 days, or 31 days, or anything in between.
> 2 months can be anything from 59 to 62 days.
> > 
> > A month is an imprecise measure, and adding them together
> will get you an even more imprecise result.
> > 
> > Deal with it -- that's just the way it is.
> > 
> > Cheers!
> 
> And now you tell me how the strtotime function tells what to use
> either 28 days or 31 days or 4 3/87 days.

It's very simple.  It uses the same day-of-the-month you start from: 1st gets 
you the 1st; 15th gets you the 15th; 31st gets you 31st or equivalent).  Put 
another way, "+1 month" adds as many days as there are days in the starting 
month; "+2 months" adds as many days as there are in the starting month and the 
one after (starting in Jan: 31+28 = 59 -- but starting in, say, Jul: 31+31 = 
62); and so on.

Most of the time this gives you exactly what you want -- it's only when you ask 
starting from the 29th, 30th or 31st of a month, and the destination month is 
shorter, that it causes any kind of problem.  Since this is a very small, 
well-defined range of dates, it's fairly simple to deal with it -- once you 
know you need to!!

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strange behaviour with strtotime()

2006-01-31 Thread James Benson
cheers for the help :)






Barry wrote:
> Ford, Mike wrote:
>> Yes, but 1 apple is 1 apple is 1 apple.
>>
>> 1 month can be 28 days, or 31 days, or anything in between. 2 months
>> can be anything from 59 to 62 days.
>>
>> A month is an imprecise measure, and adding them together will get you
>> an even more imprecise result.
>>
>> Deal with it -- that's just the way it is.
>>
>> Cheers!
> 
> And now you tell me how the strtotime function tells what to use
> either 28 days or 31 days or 4 3/87 days.
> 
> And that would help.
> 
>> Deal with it -- that's just the way it is.
> 
> It's not a bug, it's a feature!
> 
> Yeah sure ...

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strange behaviour with strtotime()

2006-01-31 Thread Barry

Ford, Mike wrote:

Yes, but 1 apple is 1 apple is 1 apple.

1 month can be 28 days, or 31 days, or anything in between. 2 months can be 
anything from 59 to 62 days.

A month is an imprecise measure, and adding them together will get you an even 
more imprecise result.

Deal with it -- that's just the way it is.

Cheers!


And now you tell me how the strtotime function tells what to use
either 28 days or 31 days or 4 3/87 days.

And that would help.

> Deal with it -- that's just the way it is.

It's not a bug, it's a feature!

Yeah sure ...
--
Smileys rule (cX.x)C --o(^_^o)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] strange behaviour with strtotime()

2006-01-31 Thread Ford, Mike
On 31 January 2006 14:52, Barry wrote:

> Ford, Mike wrote:
> > On 31 January 2006 14:12, Barry wrote:
> > 
> > 
> > > Barry wrote:
> > > Last try:
> > > Edit:
> > > >  > also 31st January -> +2 Month -> is for me 3rd April  >  >
> > > >  > 31st March is not true because i miss "3" (!!) days.  >
> > 
> > 
> > Huh?  Are you saying that, for you:
> > 
> >strtotime("+2 months");
> > 
> > gives 3rd April?  If so, I would be absolutely amazed,
> because I get 31st March, which is exactly what I expect.
> > 
> > Of course, if you add 1 month to 31st Jan, then add 1 month
> to the result, you will get 3rd April -- but that's not the
> same as simply adding 2 months to 31st Jan.  If you want 2
> months from today, ask for 2 months from today -- not 1 month
> from 1 month from today!!
> > 
> Thats not logic at all.
> 
> If you want 2 apples ask for two ones. Not for one apple and one more
> apple. Because you would just get 1 1/2. Wtf!?

Yes, but 1 apple is 1 apple is 1 apple.

1 month can be 28 days, or 31 days, or anything in between. 2 months can be 
anything from 59 to 62 days.

A month is an imprecise measure, and adding them together will get you an even 
more imprecise result.

Deal with it -- that's just the way it is.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strange behaviour with strtotime()

2006-01-31 Thread Barry

Ford, Mike wrote:

On 31 January 2006 14:12, Barry wrote:



Barry wrote:
Last try:
Edit:
>  > also 31st January -> +2 Month -> is for me 3rd April  >  >
>  > 31st March is not true because i miss "3" (!!) days.  >



Huh?  Are you saying that, for you:

   strtotime("+2 months");

gives 3rd April?  If so, I would be absolutely amazed, because I get 31st 
March, which is exactly what I expect.

Of course, if you add 1 month to 31st Jan, then add 1 month to the result, you 
will get 3rd April -- but that's not the same as simply adding 2 months to 31st 
Jan.  If you want 2 months from today, ask for 2 months from today -- not 1 
month from 1 month from today!!


Thats not logic at all.

If you want 2 apples ask for two ones. Not for one apple and one more 
apple. Because you would just get 1 1/2. Wtf!?


O_o

--
Smileys rule (cX.x)C --o(^_^o)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] strange behaviour with strtotime()

2006-01-31 Thread Ford, Mike
On 31 January 2006 14:12, Barry wrote:

> Barry wrote:
> Last try:
> Edit:
>  >  > also 31st January -> +2 Month -> is for me 3rd April  >  >
>  >  > 31st March is not true because i miss "3" (!!) days.  >

Huh?  Are you saying that, for you:

   strtotime("+2 months");

gives 3rd April?  If so, I would be absolutely amazed, because I get 31st 
March, which is exactly what I expect.

Of course, if you add 1 month to 31st Jan, then add 1 month to the result, you 
will get 3rd April -- but that's not the same as simply adding 2 months to 31st 
Jan.  If you want 2 months from today, ask for 2 months from today -- not 1 
month from 1 month from today!!

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] strange behaviour with strtotime()

2006-01-31 Thread Ford, Mike
On 31 January 2006 13:04, James Benson wrote:

> "Because 1 month from 31-Jan is 31-Feb -- which is taken to
> mean 02-Mar,
> hence the output of date("M" ...)."
> 
> 
> 
> why though, one month from now is 31 Feb, why would it take it as
> something else? 
> 
> That does not make sense to me!

Well does 31st February make sense to you??

It *has* to take it as something else, and the most obvious thing to take it
as is 3rd March (not 2nd -- I was wrong before as 2006 is not a leap year!)
which is the day that would be 31st Feb if it existed...!!!

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] strange behaviour with strtotime()

2006-01-31 Thread Ford, Mike
On 31 January 2006 13:50, James Benson wrote:

> Barry wrote:
> > Ford, Mike wrote:
> > 
> > > 
> > > Because 1 month from 31-Jan is 31-Feb -- which is taken to mean
> > > 02-Mar, hence the output of date("M" ...).
> > > 
> > > 2 months from now is 31-Mar, which is ok; 3 months from now would
> > > be 31-Apr, which would likewise be taken to mean 01-May.
> > > 
> > > This is all as expected -- no bug here.
> > > 
> > > Cheers!
> > > 
> > > Mike
> > > 
> > so the 31 feb would be 30 days right?
> > and since +1 month would be 2nd march wouldnt be +2 month then 2nd
> > april? Sinze its 2nd march +1 month 
> > 
> > see ->
> > echo strftime("%d %m %Y",strtotime ("+1
> > Month",mktime(13,0,0,3,2,2006)))."\n";
> > 
> > ^^ gives 2nd april! ^^
> > 
> > echo "date 1:".strftime("%d %m %Y",strtotime ("+1
> > Month",strtotime("+1 Month")))."\n"; 
> > 
> > ^^ gives 3rd april ^^
> > 
> > So its not logic.
> > month +2 should output 2nd april!
> > 
> > Barry
> 
> 
> 
> ok i understand now, that is fairly fd up if you ask me, the
> documentation should state this side affect, one month should be one
> month from that date not +31 days, if i wated +31 days i
> would ask for it :)

Well, it's not always 31 days from now -- that depends on the month!  For 
strtotime(), +1 month is always the same day-of-the-month in the next month -- 
so in some months that's 31 days away, others it's 30 days away, and in 
February it's 28 or 29 days away.

The problem comes when you ask for "+1 month" (or "next month") from the 31st 
of a long month -- do you mean "the last day of next month" or do you mean "the 
equivalent of 31st of next month"?  strtotime() takes the latter approach, but 
of course that's not always what you want.  In those cases, you just have to 
beware and check your answer -- if the month component ends up 2 months away, 
instead of 1, then you need to adjust your answer back the appropriate number 
of days.  Personally, I find mktime() more suited to this task than strtotime() 
as you're working with specific day/month/year numbers, but use whatever you 
find most comfortable.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strange behaviour with strtotime()

2006-01-31 Thread Barry

Barry wrote:

Barry wrote:


Ford, Mike wrote:



Uhm -- my mistake, sorry -- 31st Feb equates to 3rd March, not 2nd, 
so 3rd April here is correct.


The basic thing is that strtotime() just uses the same 
day-of-the-month when calculating in months -- so, on the 31st 
January, it reckons thus:


+1 month:  31st February -- *doesn't exist* converted to 3rd March
+2 months: 31st March-- OK
+3 months: 31st April-- *doesn't exist* converted to 1st May
+4 months: 31st May  -- OK
+5 months: 31st June -- *doesn't exist* converted to 1st July

etc., etc.

So you just have to be careful when calculating next/previous months 
to allow for strangeness like this near the end of a month -- just as 
you have to watch out for DST transitions if calculating with times 
near 01:00/02:00/03:00.  If all you're interested in is the actual 
month, your best bet is to normalize to a date that exists in every 
month (such as 1st) before doing your next/previous calculation.



Your table is quite ok.
But converting dates just because it doesnt exist and on the next 
added month doing so as if there was everything ok is a bug for me.
31st January -> +1 month -> 31st February (not possibele so its 3rd 
February) -> +1 month -> 31st February (What the O_o)


How does he calculate?
For me 3rd Fabruary -> +1 Month -> is 3rd March
also 31st January -> +2 Month -> is for me 3rd March

31st February is not true because i miss "3" (!!) days.

Not for you?

Barry



Lol f***ed everything up -_-"
edit:
 > 31st January -> +1 month -> 31st February (not possibele so its 3rd
 > March) -> +1 month -> 31st march (What the O_o)

For me 3rd Fabruary -> +1 Month -> is 3rd March
 > also 31st January -> +2 Month -> is for me 3rd March
 >
 > 31st February is not true because i miss "3" (!!) days.


Last try:
Edit:
>  > also 31st January -> +2 Month -> is for me 3rd April
>  >
>  > 31st March is not true because i miss "3" (!!) days.
>

--
Smileys rule (cX.x)C --o(^_^o)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strange behaviour with strtotime()

2006-01-31 Thread Barry

Barry wrote:

Ford, Mike wrote:



Uhm -- my mistake, sorry -- 31st Feb equates to 3rd March, not 2nd, so 
3rd April here is correct.


The basic thing is that strtotime() just uses the same 
day-of-the-month when calculating in months -- so, on the 31st 
January, it reckons thus:


+1 month:  31st February -- *doesn't exist* converted to 3rd March
+2 months: 31st March-- OK
+3 months: 31st April-- *doesn't exist* converted to 1st May
+4 months: 31st May  -- OK
+5 months: 31st June -- *doesn't exist* converted to 1st July

etc., etc.

So you just have to be careful when calculating next/previous months 
to allow for strangeness like this near the end of a month -- just as 
you have to watch out for DST transitions if calculating with times 
near 01:00/02:00/03:00.  If all you're interested in is the actual 
month, your best bet is to normalize to a date that exists in every 
month (such as 1st) before doing your next/previous calculation.



Your table is quite ok.
But converting dates just because it doesnt exist and on the next added 
month doing so as if there was everything ok is a bug for me.
31st January -> +1 month -> 31st February (not possibele so its 3rd 
February) -> +1 month -> 31st February (What the O_o)


How does he calculate?
For me 3rd Fabruary -> +1 Month -> is 3rd March
also 31st January -> +2 Month -> is for me 3rd March

31st February is not true because i miss "3" (!!) days.

Not for you?

Barry



Lol f***ed everything up -_-"
edit:
> 31st January -> +1 month -> 31st February (not possibele so its 3rd
> March) -> +1 month -> 31st march (What the O_o)

For me 3rd Fabruary -> +1 Month -> is 3rd March
> also 31st January -> +2 Month -> is for me 3rd March
>
> 31st February is not true because i miss "3" (!!) days.

--
Smileys rule (cX.x)C --o(^_^o)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strange behaviour with strtotime()

2006-01-31 Thread Barry

Ford, Mike wrote:


Uhm -- my mistake, sorry -- 31st Feb equates to 3rd March, not 2nd, so 3rd 
April here is correct.

The basic thing is that strtotime() just uses the same day-of-the-month when 
calculating in months -- so, on the 31st January, it reckons thus:

+1 month:  31st February -- *doesn't exist* converted to 3rd March
+2 months: 31st March-- OK
+3 months: 31st April-- *doesn't exist* converted to 1st May
+4 months: 31st May  -- OK
+5 months: 31st June -- *doesn't exist* converted to 1st July

etc., etc.

So you just have to be careful when calculating next/previous months to allow 
for strangeness like this near the end of a month -- just as you have to watch 
out for DST transitions if calculating with times near 01:00/02:00/03:00.  If 
all you're interested in is the actual month, your best bet is to normalize to 
a date that exists in every month (such as 1st) before doing your next/previous 
calculation.


Your table is quite ok.
But converting dates just because it doesnt exist and on the next added 
month doing so as if there was everything ok is a bug for me.
31st January -> +1 month -> 31st February (not possibele so its 3rd 
February) -> +1 month -> 31st February (What the O_o)


How does he calculate?
For me 3rd Fabruary -> +1 Month -> is 3rd March
also 31st January -> +2 Month -> is for me 3rd March

31st February is not true because i miss "3" (!!) days.

Not for you?

Barry


--
Smileys rule (cX.x)C --o(^_^o)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] strange behaviour with strtotime()

2006-01-31 Thread Ford, Mike
On 31 January 2006 13:13, Barry Krein wrote:

> Ford, Mike wrote:
> 
> > 
> > Because 1 month from 31-Jan is 31-Feb -- which is taken to
> mean 02-Mar, hence the output of date("M" ...).
> > 
> > 2 months from now is 31-Mar, which is ok; 3 months from now
> would be 31-Apr, which would likewise be taken to mean 01-May.
> > 
> > This is all as expected -- no bug here.
> > 
> > Cheers!
> > 
> > Mike
> > 
> so the 31 feb would be 30 days right?
> and since +1 month would be 2nd march wouldnt be +2 month
> then 2nd april?
> Sinze its 2nd march +1 month
> 
> see ->
> echo strftime("%d %m %Y",strtotime ("+1
> Month",mktime(13,0,0,3,2,2006)))."\n";
> 
> ^^ gives 2nd april! ^^
> 
> echo "date 1:".strftime("%d %m %Y",strtotime ("+1
> Month",strtotime("+1 Month")))."\n"; 
> 
> ^^ gives 3rd april ^^

Uhm -- my mistake, sorry -- 31st Feb equates to 3rd March, not 2nd, so 3rd 
April here is correct.

The basic thing is that strtotime() just uses the same day-of-the-month when 
calculating in months -- so, on the 31st January, it reckons thus:

+1 month:  31st February -- *doesn't exist* converted to 3rd March
+2 months: 31st March-- OK
+3 months: 31st April-- *doesn't exist* converted to 1st May
+4 months: 31st May  -- OK
+5 months: 31st June -- *doesn't exist* converted to 1st July

etc., etc.

So you just have to be careful when calculating next/previous months to allow 
for strangeness like this near the end of a month -- just as you have to watch 
out for DST transitions if calculating with times near 01:00/02:00/03:00.  If 
all you're interested in is the actual month, your best bet is to normalize to 
a date that exists in every month (such as 1st) before doing your next/previous 
calculation.

HTH

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strange behaviour with strtotime()

2006-01-31 Thread James Benson


Barry wrote:
> Ford, Mike wrote:
> 
>>
>> Because 1 month from 31-Jan is 31-Feb -- which is taken to mean
>> 02-Mar, hence the output of date("M" ...).
>>
>> 2 months from now is 31-Mar, which is ok; 3 months from now would be
>> 31-Apr, which would likewise be taken to mean 01-May.
>>
>> This is all as expected -- no bug here.
>>
>> Cheers!
>>
>> Mike
>>
> so the 31 feb would be 30 days right?
> and since +1 month would be 2nd march wouldnt be +2 month then 2nd april?
> Sinze its 2nd march +1 month
> 
> see ->
> echo strftime("%d %m %Y",strtotime ("+1
> Month",mktime(13,0,0,3,2,2006)))."\n";
> 
> ^^ gives 2nd april! ^^
> 
> echo "date 1:".strftime("%d %m %Y",strtotime ("+1 Month",strtotime("+1
> Month")))."\n";
> 
> ^^ gives 3rd april ^^
> 
> So its not logic.
> month +2 should output 2nd april!
> 
> Barry



ok i understand now, that is fairly fd up if you ask me, the
documentation should state this side affect, one month should be one
month from that date not +31 days, if i wated +31 days i would ask for it :)





James



-

Master CIW Designer  http://www.ciwcertified.com
Zend Certified Engineer  http://www.zend.com


http://www.jamesbenson.co.uk

-

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strange behaviour with strtotime()

2006-01-31 Thread Barry

Ford, Mike wrote:



Because 1 month from 31-Jan is 31-Feb -- which is taken to mean 02-Mar, hence the output 
of date("M" ...).

2 months from now is 31-Mar, which is ok; 3 months from now would be 31-Apr, 
which would likewise be taken to mean 01-May.

This is all as expected -- no bug here.

Cheers!

Mike


so the 31 feb would be 30 days right?
and since +1 month would be 2nd march wouldnt be +2 month then 2nd april?
Sinze its 2nd march +1 month

see ->
echo strftime("%d %m %Y",strtotime ("+1 
Month",mktime(13,0,0,3,2,2006)))."\n";


^^ gives 2nd april! ^^

echo "date 1:".strftime("%d %m %Y",strtotime ("+1 Month",strtotime("+1 
Month")))."\n";


^^ gives 3rd april ^^

So its not logic.
month +2 should output 2nd april!

Barry
--
Smileys rule (cX.x)C --o(^_^o)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strange behaviour with strtotime()

2006-01-31 Thread Barry Krein

Ford, Mike wrote:



Because 1 month from 31-Jan is 31-Feb -- which is taken to mean 02-Mar, hence the output 
of date("M" ...).

2 months from now is 31-Mar, which is ok; 3 months from now would be 31-Apr, 
which would likewise be taken to mean 01-May.

This is all as expected -- no bug here.

Cheers!

Mike


so the 31 feb would be 30 days right?
and since +1 month would be 2nd march wouldnt be +2 month then 2nd april?
Sinze its 2nd march +1 month

see ->
echo strftime("%d %m %Y",strtotime ("+1
Month",mktime(13,0,0,3,2,2006)))."\n";

^^ gives 2nd april! ^^

echo "date 1:".strftime("%d %m %Y",strtotime ("+1 Month",strtotime("+1
Month")))."\n";

^^ gives 3rd april ^^

So its not logic.
month +2 should output 2nd april!

Barry
--
Smileys rule (cX.x)C --o(^_^o)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strange behaviour with strtotime()

2006-01-31 Thread James Benson
"Because 1 month from 31-Jan is 31-Feb -- which is taken to mean 02-Mar,
hence the output of date("M" ...)."



why though, one month from now is 31 Feb, why would it take it as
something else?

That does not make sense to me!



James





-

Master CIW Designer  http://www.ciwcertified.com
Zend Certified Engineer  http://www.zend.com


http://www.jamesbenson.co.uk

-

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] strange behaviour with strtotime()

2006-01-31 Thread Ford, Mike
On 31 January 2006 11:24, James Benson wrote:

> Im encountering some very weird behaviour when using the following:-
> 
> 
> echo date("M", strtotime("next month"));
> 
> 
> outputs: Mar
> 
> 
> 
> while
> 
> 
> echo date("r",time());
> 
> outputs: Tue, 31 Jan 2006 11:21:47 +
> 
> 
> 
> anyone know why?

Because 1 month from 31-Jan is 31-Feb -- which is taken to mean 02-Mar, hence 
the output of date("M" ...).

2 months from now is 31-Mar, which is ok; 3 months from now would be 31-Apr, 
which would likewise be taken to mean 01-May.

This is all as expected -- no bug here.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php