project3 Posted February 15, 2008 Share Posted February 15, 2008 hello, I am trying to take the time in 12 hour format and make it into some kind of number. strtotime does that for me but is it based on the date? like what I have is times a restaurant is open so like say between 10:00 am and 8:00 pm I want to take current time in number format so that I can compare it to pull db records. is there a way to do this. or is strtotime correct way to do it. Quote Link to comment Share on other sites More sharing options...
craygo Posted February 15, 2008 Share Posted February 15, 2008 strtotime does give you a specific date if you store the open and close times in the database in 24 hour format you can make it easier to compare in the database you have 2 fields open close 10 20 now you can make today into just a number with date $hour = date("G"); then when you want to display the results you can just convert it to 12 hour format ray Quote Link to comment Share on other sites More sharing options...
project3 Posted February 15, 2008 Author Share Posted February 15, 2008 strtotime does give you a specific date if you store the open and close times in the database in 24 hour format you can make it easier to compare in the database you have 2 fields open close 10 20 now you can make today into just a number with date $hour = date("G"); then when you want to display the results you can just convert it to 12 hour format ray I don't think that will work becuase: say its open 1:00 pm to 12:00 am open close 13:00 00:00 say its 14:00 hours $time_now = "14:00"; where open < $time_now and close > $time_now since 00:00 is less won't that mess up Quote Link to comment Share on other sites More sharing options...
craygo Posted February 15, 2008 Share Posted February 15, 2008 you could always use 24 as midnight rather than 0 Quote Link to comment Share on other sites More sharing options...
project3 Posted February 15, 2008 Author Share Posted February 15, 2008 you could always use 24 as midnight rather than 0 Awesome. What happend to the topic solved link? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.