Comparison v3 - 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 Comparison v3.php
- <?php
- // 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($time2 >= $dayStartStr && $time2 <= $dayEndStr) {
- echo 'Day interval!';
- } else if ($time2 >= $nightStartStr && $time2 <= $nightEndStr) {
- echo 'Night interval!';
- }
- ?>
File Description
- Comparison v3
- PHP Code
- 15 Jan-2020
- 1.2 Kb
You can Share it:
Latest PHP Pastes