3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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;
based on X4QVb
Output for 5.6.28, 7.0.20 - 7.2.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.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
Output for 5.4.45
2016-01-06 13:13:312016-01-09 15:00:002016-01-11 08:00:00 Fatal error: Class 'DateTimeImmutable' not found in /in/TBooh on line 13
Process exited with code 255.
Output for 5.4.44
2016-01-06 13:13:322016-01-09 15:00:002016-01-11 08:00:00 Fatal error: Class 'DateTimeImmutable' not found in /in/TBooh on line 13
Process exited with code 255.
Output for 5.4.41 - 5.4.43
2016-01-06 13:13:332016-01-09 15:00:002016-01-11 08:00:00 Fatal error: Class 'DateTimeImmutable' not found in /in/TBooh on line 13
Process exited with code 255.
Output for 5.4.39 - 5.4.40
2016-01-06 13:13:342016-01-09 15:00:002016-01-11 08:00:00 Fatal error: Class 'DateTimeImmutable' not found in /in/TBooh on line 13
Process exited with code 255.
Output for 5.4.35 - 5.4.38
2016-01-06 13:13:352016-01-09 15:00:002016-01-11 08:00:00 Fatal error: Class 'DateTimeImmutable' not found in /in/TBooh on line 13
Process exited with code 255.
Output for 5.3.29, 5.4.31 - 5.4.34
2016-01-06 13:13:362016-01-09 15:00:002016-01-11 08:00:00 Fatal error: Class 'DateTimeImmutable' not found in /in/TBooh on line 13
Process exited with code 255.
Output for 5.4.25 - 5.4.30
2016-01-06 13:13:372016-01-09 15:00:002016-01-11 08:00:00 Fatal error: Class 'DateTimeImmutable' not found in /in/TBooh on line 13
Process exited with code 255.
Output for 5.3.28, 5.4.21 - 5.4.24
2016-01-06 13:13:382016-01-09 15:00:002016-01-11 08:00:00 Fatal error: Class 'DateTimeImmutable' not found in /in/TBooh on line 13
Process exited with code 255.
Output for 5.3.26 - 5.3.27, 5.4.17 - 5.4.20
2016-01-06 13:13:392016-01-09 15:00:002016-01-11 08:00:00 Fatal error: Class 'DateTimeImmutable' not found in /in/TBooh on line 13
Process exited with code 255.
Output for 5.3.21 - 5.3.25, 5.4.11 - 5.4.16
2016-01-06 13:13:402016-01-09 15:00:002016-01-11 08:00:00 Fatal error: Class 'DateTimeImmutable' not found in /in/TBooh on line 13
Process exited with code 255.