08-23-2006, 04:00 PM
I am setting up a form to except time I've set up 3 drop down boxes
- Hour (1 - 12)
- Min (15, 30, 45)
- AM or PM
what's the best way to get these three post values into a format to store in a MySQL time field
08-23-2006, 04:17 PM
Here are your options:
I didn't see an option to specify AM/PM so I'm assuming you'll need to do something like add 12 to the hour if PM is selected.
08-23-2006, 04:23 PM
Concatenate your values and use MySQL's STR_TO_DATE function as you insert:
(STR_TO_DATE('12:15 AM','%l:%i %p'))
That time will be inserted as '00:15:00'.
08-23-2006, 04:49 PM
Oooh I forgot about STR_TO_DATE; I like that answer a lot better!
08-23-2006, 05:39 PM
Thanks guys, got it workin. Now all I need to make me happy is some cold weather and snow on the ground.