Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jul 2004
    Location
    Utah, USA
    Posts
    70
    Thanks
    1
    Thanked 0 Times in 0 Posts

    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.

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    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.

  • #3
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    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.

  • #4
    New Coder
    Join Date
    Jul 2004
    Location
    Utah, USA
    Posts
    70
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks for the help. I think I got it with a combination of strtotime() and strftime().


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •