How PHP determines the current time within a certain time frame

Source: Internet
Author: User
Tags date now
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.

    • SQL Code

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

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.