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?
How do you make time judgments?
------Solution--------------------
WHERE now () between ' program start time ' and ' Program End Time ';
------Solution--------------------
This has nothing to do with your SQL. Your schedule is currently irregular, and even if there is a chance that the demand will change, just add an expiration period to your schedule.
------Solution--------------------
LZ better be able to list the table in detail.
SQL Code
SELECT * from ' table ' WHERE current_time () between ' Start time ' and ' End Time ';
------Solution--------------------
Can a database be stored in an area? A beginning one ends. Isn't that a good thing?
------Solution--------------------
If your program is cyclical, there are multiple judgments to pull.
Swtch ($weeks) {
Case 1:
3:00-5:00->a program table, 5:00-6:00->b program table,6:00-9:00-> Schedule C} such (make the corresponding judgment can be)
Case 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)
}
------Solution--------------------
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.
------Solution--------------------
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
------Solution--------------------
The answer to the 14 floor is the most reliable, I agree.