|
|
|
สอบถามการตั้งค่า วันเวลาในการเข้าใช้งานของ user ครับ |
|
|
|
|
|
|
|
Code (PHP)
<?php
$dateTimeString = '2019-08-07 11:21:24';
$DateTime = new \DateTime($dateTimeString);
echo 'checking for date/time: ' . $dateTimeString . '<br>' . PHP_EOL;
$dayNumeric = $DateTime->format('w');
echo 'Day: ' . $dayNumeric . ' (0 = Sunday, 6 = Saturday).<br>' . PHP_EOL;
echo 'Readable day: ' . $DateTime->format('l') . '<br>' . PHP_EOL;
// 0=sun, 1=mon, 2=tue, ..., 6=sat.
echo 'Monday - Saturday? ' . ($dayNumeric >= 1 && $dayNumeric <= 6 ? 'Yes' : 'No') . '<br>' . PHP_EOL;
// modify to get only Hour, minute. this allow user to delay within 1 minute.
$DateTime->setTime($DateTime->format('H'), $DateTime->format('i'), 0);
echo 'Removed seconds: ' . $DateTime->format('Y-m-d H:i:s') . '<br>' . PHP_EOL;
// set new date/time object in the morning, evening for compare.
$DateTimeDateOnly = $DateTime->format('Y-m-d');
$DateTimeMorning = new \DateTime($DateTimeDateOnly . ' 08:00:00');
$DateTimeEvening = new \DateTime($DateTimeDateOnly . ' 17:00:00');
echo 'In time? ' . ($DateTime >= $DateTimeMorning && $DateTime <= $DateTimeEvening ? 'Yes' : 'No') . '<br>' . PHP_EOL;
เอาไปลองปรับใช้เอานะครับ
|
|
|
|
|
Date :
2019-08-07 21:05:49 |
By :
mr.v |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณครับ
|
|
|
|
|
Date :
2019-08-07 21:12:35 |
By :
lhumdin |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|