Time is less than

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
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Time is less than

Post by aceconcepts »

Hi,

I want to determine whether an order has been placed before 14:00:00.

My time format in the database is formatted as "H:i:s".

How can I do this:

Code: Select all

if($orderTime<=14:00:00){
   //Do something
}
Thanks.
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

It's best to convert your existing format to either a mysql datetime (if you're storing in mysql) or unix timestamps (see strtotime()) for this reason. If not, use explode() and convert each element to its respective value in seconds, add the three values together, and make the comparison.
Post Reply