Get the App
SLTechnology News&Howtos  ›  Development  › 

How does php query the time range

Shulou Source: shulou.com Published: 2022-06-02 03:25:23 09月27日 Update

The editor today will show you how to query the time range of php. The knowledge points in the article are introduced in great detail. Friends who feel helpful can browse the content of the article with the editor, hoping to help more friends who want to solve this problem to find the answer to the problem. Follow the editor to learn more about "how to query the time range of php".

Php query time range method: 1, create a PHP sample file; 2, through the "function checkIsBetweenTime ($start,$end) {...}" method to determine whether within the specified time range.

This article operating environment: windows7 system, PHP7.1 version, DELL G3 computer

How does php query the time range?

Php determines whether it is within a specified period of time.

/ * determine whether the current time is within the specified time period * @ param $start start time eg:10:30 * @ param $end end time eg:15:30 * @ author:mzc * @ date:2018/8/9 10:46 * @ return: bool 1: in the range, 0: not in the range * / function checkIsBetweenTime ($start,$end) {$date= date ('start,$end'); $curTime = strtotime ($date) / / current time $assignTime1 = strtotime ($start); / / obtain the specified minute timestamp, 00:00 $assignTime2 = strtotime ($end); / / obtain the specified minute timestamp, 01:00$ result = 0; if ($curTime > $assignTime1&&$curTime "800s" & & $time

< "1130") { // code} 二、只判断小时 date_default_timezone_set("Asia/Shanghai");if(date('G')17){ // code}$h = intval(date("H")); if($h >

23 | | $h < 7) {echo 'this is the first task';} else {echo 'this is the second task';}

3. Php judgment sentence in different periods on time

/ (Asia / Chongqing) date_default_timezone_set ('Asia/Chongqing'); / (Asia / Harbin) date_default_timezone_set (' Asia/Harbin'); / / (people's Republic of China) date_default_timezone_set ('PRC')

Thank you for your reading, the above is the full content of "php how to query the time range", learn friends to hurry up to operate it. I believe that the editor will certainly bring you better quality articles. Thank you for your support to the website!

Tags: Time scope query time time friends tasks content hours articles methods knowledge follow questions Asia help people that is documents dates Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info MariaDB Apple MySQL Xiaomi