You are here: formatting time « PHP Programming Language « IT news, forums, messages
formatting time

Posted by Mark on 04/28/06 09:49

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.

 

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

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