Page 1 of 1

PHP Time

Posted: Sun Nov 08, 2009 2:39 pm
by lewiswatson
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?

Re: PHP Time

Posted: Sun Nov 08, 2009 3:47 pm
by timWebUK
I would use 24-hour clock...

Re: PHP Time

Posted: Sun Nov 08, 2009 4:24 pm
by Apollo
If you need to compare the time values with eachother, or perform other logic on them, store the times as a linux timestamp (e.g. with mktime).

If not, just store the time as a string however the user enters it.