Home  >  Article  >  php教程  >  PHP读取日期并判断班次

PHP读取日期并判断班次

WBOY
WBOYOriginal
2016-06-13 10:53:311124browse

" size="" />

02

03 // 白班:09:00到21:00

04 // 夜班:21:00到09:00

05

06 date_default_timezone_set('PRC'); //设定时区,PRC表示中国•••

07 $hour = date('H');

08 if($hour 8){

09 echo '白班';

10 }else{

11 echo '夜班';

12 }

13 ?>

1

那么用PHP实现和JS实现有什么区别呢?

2

JS获取的是客户端的时间(也就是你电脑的时间),而PHP获取的是服务器的时间(最标准,但是如果两地时区不一就碉堡了)

 

 

Statement:
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