PHP Time

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lewiswatson
Forum Newbie
Posts: 1
Joined: Sun Nov 08, 2009 2:38 pm

PHP Time

Post 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?
User avatar
timWebUK
Forum Contributor
Posts: 239
Joined: Thu Oct 29, 2009 6:48 am
Location: UK

Re: PHP Time

Post by timWebUK »

I would use 24-hour clock...
User avatar
Apollo
Forum Regular
Posts: 794
Joined: Wed Apr 30, 2008 2:34 am

Re: PHP Time

Post 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.
Post Reply