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