Reply to Re: formatting time

Your name:

Reply:


Posted by Dana Cartwright on 04/28/06 13:27

"Mark" <mnbayazit@gmail.com> wrote in message
news:1146206995.379248.8090@i40g2000cwc.googlegroups.com...
> hi,
> how might I convert a string like "5p" or "5pm" or "5:00p" or "5.00pm"
> etc..
> to "17:00:00" (24-hour time)
> I want it so that it's really *NOT* picky and will accept just about
> anything as long as it resembles a time.
>
> Also, I have two times, a start time ($start) and an endtime ($end).
> For the end time, users should be able to enter values like "3h" or "3
> hours" or "3 hrs", "3h5min","3hrs5minutes6s" etc etc... which would
> then be added to the start time, and converted to 24-hour time again.
> basically anything that starts with "a" should be interpreted as am,
> p->pm, h->hours, m->minutes,s->seconds. the trouble I'm having is
> parsing the string, so it seperates numbers and letters, and interprets
> them properly.
>
> also, a single number like "5" would be interpreted as "17:00:00". I
> figure any number greater than 6 and less than 12 would be assumed AM,
> and "12" would be noon, and any number greater than or equal to 1 and
> less than 6 would be assumed PM if not specified. numbers greater than
> or equal to 24 could be assumed to be hours...
>
> any help would be appreciated.

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.

-Dana

[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

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