Home > Backend Development > PHP Tutorial > Two ways to determine a specified time period in PHP_PHP Tutorial

Two ways to determine a specified time period in PHP_PHP Tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 10:35:50
Original
1141 people have browsed it

Sometimes we need to perform a certain task at a certain time of the day, or perform different tasks at different hours of the day. How to achieve this using PHP? The following two examples can solve this problem. Question

1. Judgment including hours and minutes The code is as follows: date_default_timezone_set("Asia/Shanghai"); $time = intval (date("Hi")); if ($time > "800" && $time < "1130") { // code } 2. Only judge the hour The code is as follows: date_default_timezone_set("Asia/Shanghai"); if(date('G')<8 || date('G')>17) { // code }$h = intval(date("H")); if ($h > 23 || $h < 7) { echo 'Here is the first task'; } else { echo 'This is the second task'; } ​

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/741820.htmlTechArticleSometimes we need to perform a certain task at a certain time of the day, or at different hours of the day How to perform different tasks using PHP? The following two examples can be...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template