Jump to content

strtotime or timestamp


project3

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/91318-strtotime-or-timestamp/
Share on other sites

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

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

Archived

This topic is now archived and is closed to further replies.

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