PHP Time Comparison

Source: Internet
Author: User


/**
* PHP Time Comparison
*/
Define the start time, notice that the time is a string format, so you must enclose the error in quotation marks Otherwise, do not call me, and the colon inside must be a colon
$start _time = ' 7:00 ';

Define the end time, don't ask me why I wrote 18 in the six o'clock in the afternoon, I would suggest you re-read primary school.
$end _time = ' 18:00 ';

Get the current time period, the use of the date () function I will not talk nonsense, do not understand directly read the previous article or Google
$now _time = Date (' h:i ');

Judge
if ($start _time<= $now _time && $end _time>= $now _time) {
Echo ' I want to post a message! ‘;
}else{
Echo ' elder brother, now only what time AH ~ ~ ~ People have not been awake yet!!! ‘;
}

PHP Time Comparison

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.