我網站現在的限制訪問時間段是24小時制,也就是可以從開始時間00:01到24:00結束,現在我想要從開始時間10:00到02:00結束就用不了,請問怎麼用代碼可以這樣限制時間訪問嗎?
回複討論(解決方案)
擷取目前時間,不是容許的時間段給出提示。。。
24小時制,開始時間10:00到02:00結束
這不就跨天了嗎?
所以你要分2段設定
00:00 到 02:00
10:00 到 24:00
24小時制,開始時間10:00到02:00結束
這不就跨天了嗎?
所以你要分2段設定
00:00 到 02:00
10:00 到 24:00
能發下代碼嗎?
你原來只有類似
date('H:i') >= $起始時間 and date('H:i') < 結束時間
這樣一條判別
加一條判別就是
date('H:i') >= $起始時間1 and date('H:i') < 結束時間1
or
date('H:i') >= $起始時間2 and date('H:i') < 結束時間2
你原來只有類似
date('H:i') >= $起始時間 and date('H:i') < 結束時間
這樣一條判別
加一條判別就是
date('H:i') >= $起始時間1 and date('H:i') < 結束時間1
or
date('H:i') >= $起始時間2 and date('H:i') < 結束時間2
這樣不起衝突嗎?
你原來只有類似
date('H:i') >= $起始時間 and date('H:i') < 結束時間
這樣一條判別
加一條判別就是
date('H:i') >= $起始時間1 and date('H:i') < 結束時間1
or
date('H:i') >= $起始時間2 and date('H:i') < 結束時間2
版主,麻煩給個完整的代碼。
沖什麼突?
你原來只有類似
date('H:i') >= $起始時間 and date('H:i') < 結束時間
這樣一條判別
加一條判別就是
date('H:i') >= $起始時間1 and date('H:i') < 結束時間1
or
date('H:i') >= $起始時間2 and date('H:i') < 結束時間2
這樣不起衝突嗎?
沖什麼突?
你原來只有類似
date('H:i') >= $起始時間 and date('H:i') < 結束時間
這樣一條判別
加一條判別就是
date('H:i') >= $起始時間1 and date('H:i') < 結束時間1
or
date('H:i') >= $起始時間2 and date('H:i') < 結束時間2
這樣不起衝突嗎?
版主,麻煩發個全部代碼好嗎?
自己不會寫?
那就把你原來的這部分貼出來
不然我給你寫了,你也弄不進去
自己不會寫?
那就把你原來的這部分貼出來
不然我給你寫了,你也弄不進去
//提示時間檢查$fromTime=strtotime(date('Y-m-d ',$this->time).$this->settings['cashFromTime'].':00');$toTime=strtotime(date('Y-m-d ',$this->time).$this->settings['cashToTime'].':00');if($this->time < $fromTime ||$this->time > $toTime ) throw new Exception("對不起,已過提現時間,請在合適的時間提交!
提現時間:".$this->settings['cashFromTime']." ~ ".$this->settings['cashToTime']);$this->beginTransaction();try{$this->freshSession();if($this->user['coinPassword']!=md5($para['coinpwd'])) throw new Exception('資金密碼不正確');unset($para['coinpwd']);if($this->user['coin']<$para['amount']) throw new Exception('你帳戶資金不足');
這是代碼
訪問的時候你用php調取目前時間判斷,如果是在允許時間內就繼續運行,否則打道回府!
訪問的時候你用php調取目前時間判斷,如果是在允許時間內就繼續運行,否則打道回府!
//提示時間檢查$fromTime=strtotime(date('Y-m-d ',$this->time).$this->settings['cashFromTime'].':00');$toTime=strtotime(date('Y-m-d ',$this->time).$this->settings['cashToTime'].':00');if($this->time < $fromTime ||$this->time > $toTime ) throw new Exception("對不起,已過提現時間,請在合適的時間提交!
提現時間:".$this->settings['cashFromTime']." ~ ".$this->settings['cashToTime']);$this->beginTransaction();try{$this->freshSession();if($this->user['coinPassword']!=md5($para['coinpwd'])) throw new Exception('資金密碼不正確');unset($para['coinpwd']);if($this->user['coin']<$para['amount']) throw new Exception('你帳戶資金不足');
目前是24小時制的,我需要的是跨天時間,比如08點到02點,上面是我的PHP代碼,請問怎麼改?
strtotime(date("Y-m-d"));//00:00strtotime(date("Y-m-d 02:00"));//02:00strtotime(date("Y-m-d 22:00"));//22:00strtotime(date("Y-m-d 24:00"));//24:00