You are here: Re: Time + 10 minutes « PHP Programming Language « IT news, forums, messages
Re: Time + 10 minutes

Posted by Rik on 01/06/07 01:44

Michael Fesser wrote:
> .oO(Moot)
>
>> Agreed. strtotime has some annoying flaws that aren't officially
>> documented. For an illustration, try the following code:
>> [...]
>>
>> This example shows how strtotime's handling of months could really
>> screw up logic expecting it to work in a different way than it
>> actually does (I should know, I've learned it the hard way). Since
>> there are 28 days in Feb, strtotime adds the 3 extra days (to 31)
>> and ends up at March 3rd, similar problem with April, which has 30
>> days, so the extra 1 puts it to May 1st.
>
> This behaviour is documented:
>
>> The fuzz in units can cause problems with relative items. For
>> example, `2003-07-31 -1 month' might evaluate to 2003-07-01, because
>> 2003-06-31 is an invalid date. To determine the previous month more
>> reliably, you can ask for the month before the 15th of the current
>> month. [...]
>
> http://www.gnu.org/software/tar/manual/html_node/tar_115.html#SEC115

Yup, this is actually not one of the things I would qualify as
unpredictable behviour, yet it's understandable that with a syntax like
strtotime people understand it to work.

In the same ballpark of unexpected yet highly logical behaviour:

echo date('r',mktime(0,0,0,0,0,2007));

Unexpected for most, but highly logical nonetheless ;)
--
Rik Wasmus

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация