Jump to content

Converting a string to time


BelowZero

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/258408-converting-a-string-to-time/
Share on other sites

<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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.