PHP reads the date and determines the shift_PHP tutorial
WBOY
Release: 2016-07-14 10:07:26
Original
1007 people have browsed it
02
03// Day shift: 09:00 to 21:00
04// Night shift: 21:00 to 09:00
05
06date_default_timezone_set('PRC'); //Set the time zone, PRC means China •••
07$hour = date('H');
08if($hour <= 20 && $hour > 8){
09echo 'Day shift';
10}else{
11echo 'night shift';
12}
13?>
1
So what is the difference between PHP implementation and JS implementation?
2
JS gets the client time (that is, the time of your computer), while PHP gets the server time (the most standard, but if the time zones of the two places are different, it will Blockhouse)
http://www.bkjia.com/PHPjc/477866.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/477866.htmlTechArticleinput name=riqi class=Wdate type=text id=riqi value=?=date(Y-m-d)? size= / 02 ?php 03 // Day shift: 09:00 to 21:00 04 // Night shift: 21:00 to 09:00 05 06 date_default_timezone_set(...
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