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
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

Link to comment
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

 

 

 

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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