BelowZero Posted March 6, 2012 Share Posted March 6, 2012 I have a dropdown box filled with times in a form: <select name = "closetime"> <option>Choose One</option> <option>All Day</option> <option>7:00 am</option> <option>8:00 am</option> <option>9:00 am</option> <option>10:00 am</option> <option>11:00 am</option> How do I convert "closetime" to a time format ($closetime) that I can insert into my database? I'm assuming that at some point in the code I'll use strtotime, but I'm not sure where... Inside the option tags?, or after "closetime" has a value?, or after "closetime" is sent to a processing file? Any ideas? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/258408-converting-a-string-to-time/ Share on other sites More sharing options...
Pikachu2000 Posted March 6, 2012 Share Posted March 6, 2012 <option value="07:00">7:00am</option> . . . <option value="23:00">11:00pm</option> You might want to set up an array with the values in it, so you can just loop the array to build the <option> list. Just a thought. Quote Link to comment https://forums.phpfreaks.com/topic/258408-converting-a-string-to-time/#findComment-1324574 Share on other sites More sharing options...
BelowZero Posted March 6, 2012 Author Share Posted March 6, 2012 Yes, of course. Works like a charm. Thanks Pikachu2000! Quote Link to comment https://forums.phpfreaks.com/topic/258408-converting-a-string-to-time/#findComment-1324577 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.