Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does php query the time range

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report