3

Possible Duplicate:
How to check if a date is in a given range of day+month?

How would I go about checking to see if the current time is between two different time intervals?

Here's a practical example: Let's say Dan is only around from 1PM - 4PM, how would I make a script to check to see if the current time is between 1PM and 4PM. I want to use this to display a list of currently available rep's based on their schedule that's inputted into a database.

Community
  • 1
  • 1
tkecode
  • 67
  • 1
  • 3

1 Answers1

16

use H from date - 24-hour format of an hour:

if( (date('H') >= 13) && (date('H') < 16) ){
    // between 1PM and 4PM
}
Mihai Iorga
  • 39,330
  • 16
  • 106
  • 107