Reply to Re: formatting time

Your name:

Reply:


Posted by Rik on 04/28/06 22:09

Dana Cartwright wrote:
> You haven't said anything about reading the PHP manual. So I'll
> assume you haven't (which is a no-no). Go read the manual, looking
> at strtotime() and date(), and then if you don't see how to do what
> you want, come back here and ask more specific questions.

strtotime() is highly unreliable in my experience, it just tries to make the
best of it.
A whopper of a regex and preg_replace could try to take care of it, but it
is a lot of work to catch all possible formats as described.

Personally, I wouldn't consider even writing this kind of code, unless
forced by an already existing badly configured database.

> For the end time, users should be able to enter values like "3h" or "3
> hours" or "3 hrs", "3h5min","3hrs5minutes6s" etc etc...

If I'd write the required script/application/whatever I'd make it impossible
to enter values like this. In a webpage I would create 2 simple select
lists: one with hours and one with minutes, takes care if the whole deal.
Controlling user-input is more reliable and a hell of a lot less work
compared to guessing what users are trying to do.

Grtz,
--
Rik Wasmus

[Back to original 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

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