Intervale orare - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of Intervale orare.php
- <?php
- $time = date('Y-m-d 08:30:00');
- if($time >= date('Y-m-d 00:00:00') && $time <= date('Y-m-d 05:59:59')){
- echo 'nigh interval';
- }
- if($time >= date('Y-m-d 06:00:00') && $time <= date('Y-m-d 21:59:59')){
- echo 'day interval';
- }
- if($time >= date('Y-m-d 22:00:00') && $time <= date('Y-m-d 23:59:59')){
- echo 'nigh interval';
- }
- exit;
- // Time Test
- $nowTime = time();
- $time1 = date('H:i:s', strtotime($nowTime));
- $time2 = date('H:i:s', strtotime('01:30'));
- // Day interval
- $dayStartStr = date('H:i:s', strtotime('06:00:00'));
- //$dayStartInt = DateTime::createFromFormat('Y-m-d H:i:s', $dayStartStr);
- $dayEndStr = date('H:i:s', strtotime('21:59:00'));
- //$dayEndInt = DateTime::createFromFormat('Y-m-d H:i:s', $dayEndStr);
- // Night interval
- $nightStartStr = date('H:i:s', strtotime('22:00:00'));
- //$nightStartInt = DateTime::createFromFormat('Y-m-d H:i:s', $nightStartStr);
- $nightEndStr = date('H:i:s', strtotime('05:59:00'));
- //$nightEndInt = DateTime::createFromFormat('Y-m-d H:i:s', $nightEndStr);
- /*$interval = $nightStartInt->diff($nightEndInt);
- $total = $interval->format("%H:%I");
- echo $total;*/
- if(strtotime($time2) >= strtotime($dayStartStr) && strtotime($time2) <= strtotime($dayEndStr)) {
- echo 'Day interval!';
- } else if (strtotime($time2) >= strtotime($nightStartStr) && strtotime($time2) <= strtotime($nightEndStr)) {
- echo 'Night interval!';
- }
- ?>
File Description
- Intervale orare
- PHP Code
- 15 Jan-2020
- 1.64 Kb
You can Share it:
Latest PHP Pastes