Jump to content

Recommended Posts

What is the best way with PHP and MySQL to handle time?

 

In example, I have a form where the user can type in a time (12:00, 1:15) and select AM/PM from a pull down menu. The problem is I need it to display in order (12 AM is before 12 PM).

 

How can I solve that with PHP / MySQL? Thanks!

Link to comment
https://forums.phpfreaks.com/topic/180702-php-time/
Share on other sites

I don't actually have the code yet.

 

Concept only: I have a form that has two fields:

 

- Time (ex: user input would be 9:15)

- AM / PM selection

 

The problem I anticipate is how PHP will display the results correctly since it cannot differentiate AM / PM if I just store the result in MySQL as, for example, "9:15 AM"

 

So my question is, how do I take user inputted times and AM / PM and store / retrieve properly?

Link to comment
https://forums.phpfreaks.com/topic/180702-php-time/#findComment-953485
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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