ตั้งวัน-เวลาเพื่อให้เว็บแอพหยุดทำงาน

<?php

// ยกเลิกการใช้งานในช่วงเวลา
$CurDate = strtotime(date("Y-m-d H:i:s"));
$BeginDate = strtotime("2016-10-01 00:00:01"); // จากวันที่
$EndDate = strtotime("2016-10-10 23:59:59"); // ถึงวันที่
$BeginTime = '09:55:00'; // จากเวลา
$EndTime = '10:20:00'; // ถึงเวลา
if($CurDate > $BeginDate and $CurDate < $EndDate) {
$fromtime = date("Y-m-d").' '.$BeginTime;
$totime = date("Y-m-d").' '.$EndTime;
if(check_time($fromtime)<=0 && check_time($totime)>=0 ){
echo "Now is :".date('l jS \of F Y h:i:s A')." <br/>We do temporary out of service between $fromtime To $totime <be/>";
die();
}
}

....
.... do your job ....
....

//(check_time('2014-10-17 12:00:00')>0?'Empty':'')
function check_time($timeconfig){
$set_time = strtotime($timeconfig);
$now_time = strtotime(date('Y-m-d H:i:s'));
return $set_time-$now_time;
}

?>

แปะไว้ก่อนครับ วันหลังค่อยมาขยายความ

แสดงความคิดเห็น

0 ความคิดเห็น