|
![](/images/resource/spacer.gif) |
|
สอบถามการตั้งค่า วันเวลาในการเข้าใช้งานของ user ครับ |
|
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
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;
เอาไปลองปรับใช้เอานะครับ
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2019-08-07 21:05:49 |
By :
mr.v |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
ขอบคุณครับ
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2019-08-07 21:12:35 |
By :
lhumdin |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
|
|
|
![](/images/digitalocean-banner.jpg)
|
Load balance : Server 00
|