3v4l.org

run code in 300+ PHP versions simultaneously
<?php $now = new DateTime; $start = new DateTime('saturday this week 15:00'); $end = new DateTime('monday next week 08:00'); $departure = new DateTime('2016-01-11 23:30:59'); echo $now->format('Y-m-d H:i:s'); echo $start->format('Y-m-d H:i:s'); echo $end->format('Y-m-d H:i:s'); if ($now > $start && $now < $end && $departure->diff($now)->hours <= 72) { echo 'Error! Please contact administrator!'; } $now = new DateTimeImmutable; $departure = $now->modify('+42 hours'); echo $now->format('Y-m-d H:i:s') . PHP_EOL; echo $departure->format('Y-m-d H:i:s') . PHP_EOL; echo $now->diff($departure)->format('%h') . PHP_EOL;
Output for 5.6.28, 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.31, 7.4.0 - 7.4.33, 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
2016-01-06 13:13:282016-01-09 15:00:002016-01-11 08:00:002016-01-06 13:13:28 2016-01-08 07:13:28 18
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 2016-01-06 13:13:282016-01-09 15:00:002016-01-11 08:00:002016-01-06 13:13:28 2016-01-08 07:13:28 18
Output for 7.3.32 - 7.3.33, 8.0.13
2016-01-06 12:13:282016-01-09 15:00:002016-01-11 08:00:002016-01-06 12:13:28 2016-01-08 06:13:28 18
Output for 7.0.6
2016-05-21 13:24:392016-05-21 15:00:002016-05-23 08:00:002016-05-21 13:24:39 2016-05-23 07:24:39 18
Output for 7.0.5
2016-04-03 09:26:192016-04-09 15:00:002016-04-11 08:00:002016-04-03 09:26:19 2016-04-05 03:26:19 18
Output for 7.0.4
2016-03-10 21:32:492016-03-12 15:00:002016-03-14 08:00:002016-03-10 21:32:49 2016-03-12 15:32:49 18
Output for 7.0.3
2016-03-18 22:57:042016-03-19 15:00:002016-03-21 08:00:002016-03-18 22:57:04 2016-03-20 16:57:04 18
Output for 7.0.2
2016-03-23 05:10:182016-03-26 15:00:002016-03-28 08:00:002016-03-23 05:10:18 2016-03-24 23:10:18 18
Output for 7.0.1
2016-03-24 08:17:162016-03-26 15:00:002016-03-28 08:00:002016-03-24 08:17:16 2016-03-26 02:17:16 18
Output for 7.0.0
2016-03-27 10:10:352016-04-02 15:00:002016-04-04 08:00:002016-03-27 10:10:35 2016-03-29 04:10:35 18
Output for 5.6.21
2016-05-02 16:19:222016-05-07 15:00:002016-05-09 08:00:002016-05-02 16:19:22 2016-05-04 10:19:22 18
Output for 5.6.20
2016-04-10 08:28:122016-04-16 15:00:002016-04-18 08:00:002016-04-10 08:28:12 2016-04-12 02:28:12 18
Output for 5.6.19
2016-03-08 05:41:092016-03-12 15:00:002016-03-14 08:00:002016-03-08 05:41:09 2016-03-09 23:41:09 18
Output for 5.6.18
2016-03-15 14:38:122016-03-19 15:00:002016-03-21 08:00:002016-03-15 14:38:12 2016-03-17 08:38:12 18
Output for 5.6.17
2016-03-20 02:10:402016-03-26 15:00:002016-03-28 08:00:002016-03-20 02:10:40 2016-03-21 20:10:40 18
Output for 5.6.16
2016-03-28 10:59:502016-04-02 15:00:002016-04-04 08:00:002016-03-28 10:59:50 2016-03-30 04:59:50 18
Output for 5.6.15
2016-03-29 11:49:082016-04-02 15:00:002016-04-04 08:00:002016-03-29 11:49:08 2016-03-31 05:49:08 18
Output for 5.6.14
2016-04-14 17:31:422016-04-16 15:00:002016-04-18 08:00:002016-04-14 17:31:42 2016-04-16 11:31:42 18
Output for 5.6.13
2016-04-15 18:10:462016-04-16 15:00:002016-04-18 08:00:002016-04-15 18:10:46 2016-04-17 12:10:46 18
Output for 5.6.12
2016-04-20 08:39:532016-04-23 15:00:002016-04-25 08:00:002016-04-20 08:39:53 2016-04-22 02:39:53 18
Output for 5.6.11
2016-04-24 15:06:022016-04-30 15:00:002016-05-02 08:00:002016-04-24 15:06:02 2016-04-26 09:06:02 18
Output for 5.6.10
2016-04-25 17:11:502016-04-30 15:00:002016-05-02 08:00:002016-04-25 17:11:50 2016-04-27 11:11:50 18
Output for 5.6.9
2016-04-27 22:37:542016-04-30 15:00:002016-05-02 08:00:002016-04-27 22:37:54 2016-04-29 16:37:54 18
Output for 5.6.8
2016-04-30 07:07:582016-04-30 15:00:002016-05-02 08:00:002016-04-30 07:07:58 2016-05-02 01:07:58 18
Output for 5.5.35
2016-05-23 02:18:472016-05-28 15:00:002016-05-30 08:00:002016-05-23 02:18:47 2016-05-24 20:18:47 18
Output for 5.5.34
2016-04-11 10:42:042016-04-16 15:00:002016-04-18 08:00:002016-04-11 10:42:04 2016-04-13 04:42:04 18
Output for 5.5.33
2016-03-09 08:40:002016-03-12 15:00:002016-03-14 08:00:002016-03-09 08:40:00 2016-03-11 02:40:00 18
Output for 5.5.32
2016-03-17 18:35:002016-03-19 15:00:002016-03-21 08:00:002016-03-17 18:35:00 2016-03-19 12:35:00 18
Output for 5.5.31
2016-03-21 05:19:372016-03-26 15:00:002016-03-28 08:00:002016-03-21 05:19:37 2016-03-22 23:19:37 18
Output for 5.5.30
2016-04-01 13:41:122016-04-02 15:00:002016-04-04 08:00:002016-04-01 13:41:12 2016-04-03 07:41:12 18
Output for 5.5.29
2016-04-17 08:28:332016-04-23 15:00:002016-04-25 08:00:002016-04-17 08:28:33 2016-04-19 02:28:33 18
Output for 5.5.28
2016-04-21 11:58:252016-04-23 15:00:002016-04-25 08:00:002016-04-21 11:58:25 2016-04-23 05:58:25 18
Output for 5.5.27
2016-04-22 13:36:542016-04-23 15:00:002016-04-25 08:00:002016-04-22 13:36:54 2016-04-24 07:36:54 18
Output for 5.5.26
2016-04-26 19:52:232016-04-30 15:00:002016-05-02 08:00:002016-04-26 19:52:23 2016-04-28 13:52:23 18
Output for 5.5.25
2016-04-29 03:18:022016-04-30 15:00:002016-05-02 08:00:002016-04-29 03:18:02 2016-04-30 21:18:02 18
Output for 5.5.24
2016-05-24 09:41:142016-05-28 15:00:002016-05-30 08:00:002016-05-24 09:41:14 2016-05-26 03:41:14 18

preferences:
152.56 ms | 401 KiB | 183 Q