PHP reads the date and determines the shift_PHP tutorial

WBOY
Release: 2016-07-14 10:07:26
Original
982 people have browsed it

02
03 // Day shift: 09:00 to 21:00
04 // Night shift: 21:00 to 09:00
05
06 date_default_timezone_set('PRC'); //Set the time zone, PRC means China •••
07 $hour = date('H');
08 if($hour <= 20 && $hour > 8){
09 echo 'Day shift';
10 }else{
11 echo '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)

www.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(...
Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template