Convert any time (from a form) into 24 hour format
Posted: Sun Aug 08, 2004 6:56 pm
I have a field in one of my forms that allows the user to enter a time. I have no set way that I ask them to enter a time but I want to be able to convert any time that is entered into a standard that I can use to add and subtract etc. In other words, a user may enter 9am or 7:15 PM and I want to convert those times into a set format that will write the same type of time to my database every time. I think that the 24 hour system would be the best format. So for the two examples above, I would want to write 09:00 and 19:15 to my database. My biggest problem is that users may enter times in strange ways. I need a way to convert each of these into a workable format. I think I will need to use some type of string replacement, but im not sure. Any ideas? I am fairly new to PHP so try not to use any fancy language when answering my question. thank you.