You are here: Re: PHP4 date parsing « PHP Language « IT news, forums, messages
Re: PHP4 date parsing

Posted by Michael Fesser on 02/26/07 22:14

..oO(Rik)

>Thank you for this wonderfull example against using strtotime(). Never
>liked the unpredictability of this function :-)

It's all documented:

| The function expects to be given a string containing a US English date
| format [...]

http://www.php.net/manual/en/function.strtotime.php

| For numeric months, the ISO 8601 format `year-month-day' is allowed
| [...] The construct `month/day/year', popular in the United States, is
| accepted. Also `month/day', omitting the year.

http://www.gnu.org/software/tar/manual/html_node/tar_111.html#SEC111

There's no word about locales, so you can't expect strtotime() to
recognize every localized date format.

In my projects I use my own date parser class, which uses some regular
expressions to recognize the most common formats (especially the German
dd.mm.yy[yy], which is what I usually need). If the matching fails, I
call strtotime() just as a fallback.

Micha

 

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

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