Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-01-2007, 07:56 PM   PM User | #1
silverskymedia
New Coder

 
Join Date: Jul 2004
Location: Utah, USA
Posts: 70
Thanks: 1
Thanked 0 Times in 0 Posts
silverskymedia is an unknown quantity at this point
Question Time From Form to Database(MySQL)

I have a form and I'm trying to decide the best way to ask the user for the time they want to schedule the event. Should I just have a text field or should I use a list with options. I would prefer to ask for the time in 12-hour format and ask whether or not it's AM/PM.

I know I will have to convert the time to 24-hour format. I'm just having trouble working out all the details of getting it from 12-hr to 24-hr so I can post it to the database.

Thanks for your help.
silverskymedia is offline   Reply With Quote
Old 03-01-2007, 08:24 PM   PM User | #2
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
I would make a single selection list that contains all the times available (10am, 11am, noon, 1pm, etc) and then use strtotime() to convert it into a "time" data type to store in MySQL.
__________________
Fumigator is offline   Reply With Quote
Old 03-01-2007, 11:07 PM   PM User | #3
aedrin
Senior Coder

 
Join Date: Jan 2007
Posts: 1,648
Thanks: 1
Thanked 58 Times in 54 Posts
aedrin will become famous soon enough
If you're generating a list of times, then why risk strtotime()?

Just use the timestamp as the value in the selection list.

But if you want non specific times (not in hour increments/not a drop down) then you should probably use strtotime().

It's quite nice as long as you guide the user somewhat.
aedrin is offline   Reply With Quote
Old 03-01-2007, 11:09 PM   PM User | #4
silverskymedia
New Coder

 
Join Date: Jul 2004
Location: Utah, USA
Posts: 70
Thanks: 1
Thanked 0 Times in 0 Posts
silverskymedia is an unknown quantity at this point
Thanks for the help. I think I got it with a combination of strtotime() and strftime().
silverskymedia is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:04 PM.


Advertisement
Log in to turn off these ads.