How does PHP determine if the current time is within a certain time frame?
I have a program table feature that outputs the schedule for the day.
There are mainly Program name program introduction and program start time and program end time.
How can I tell which is the current time output?
LZ better be able to list the table in detail.
SELECT * from ' table ' WHERE current_time () between ' Start time ' and ' End Time ';
Can a database be stored in an area? A beginning one ends. Isn't that a good thing?
If your program is cyclical, there are multiple judgments to pull.
Swtch ($weeks) {case 1:3:00-5:00->a listings, 5:00-6:00->b listings,6:00-9:00-> listings C} such (make a corresponding judgment on it can be) 2: {3:00-5:00-> ; a listings, 5:00-5:30->b listings, 5:30-6:00->d listings, 8:00-9:30->c listings} (similarly)}
Why so Tangled ...
It's a regular schedule, isn't it? So as long as the starting time of each program is recorded in the database, it is indicated by Unixtimestamp, as long as
Program Start < current time < The end of the program is all right?
Then it is time to fill out the schedule on the line.
You have given the table structure, the problem has long been solved!
Today's date now ()
How many weekday are there today (now ())
What programs are broadcast today Find_in_set (Weekday (now ()), ' Week ') Note that your week field name is the MySQL reserved word
Current Time Curtime ()
Current time in which time period curtime () between Start_time and Finish_time
Grouped together
SELECT * from Tbl_name where Find_in_set (Weekday (now ()), ' Week ') and Curtime () between Start_time and Finish_time
The above is how PHP judge the current time in a certain time range of content, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!