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-10 23:30:59'); echo $now->format('Y-m-d H:i:s'). PHP_EOL;; echo $start->format('Y-m-d H:i:s'). PHP_EOL;; echo $end->format('Y-m-d H:i:s'). PHP_EOL;; 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 h0PZp
Output for 5.6.28, 7.0.20 - 7.2.0
2016-01-06 13:14:33 2016-01-09 15:00:00 2016-01-11 08:00:00 2016-01-06 13:14:33 2016-01-08 07:14:33 18
Output for 7.0.6
2016-05-21 13:24:42 2016-05-21 15:00:00 2016-05-23 08:00:00 2016-05-21 13:24:42 2016-05-23 07:24:42 18
Output for 7.0.5
2016-04-03 09:26:21 2016-04-09 15:00:00 2016-04-11 08:00:00 2016-04-03 09:26:21 2016-04-05 03:26:21 18
Output for 7.0.4
2016-03-10 21:32:52 2016-03-12 15:00:00 2016-03-14 08:00:00 2016-03-10 21:32:52 2016-03-12 15:32:52 18
Output for 7.0.3
2016-03-18 22:57:08 2016-03-19 15:00:00 2016-03-21 08:00:00 2016-03-18 22:57:08 2016-03-20 16:57:08 18
Output for 7.0.2
2016-03-23 05:10:22 2016-03-26 15:00:00 2016-03-28 08:00:00 2016-03-23 05:10:22 2016-03-24 23:10:22 18
Output for 7.0.1
2016-03-24 08:17:19 2016-03-26 15:00:00 2016-03-28 08:00:00 2016-03-24 08:17:19 2016-03-26 02:17:19 18
Output for 7.0.0
2016-03-27 10:10:38 2016-04-02 15:00:00 2016-04-04 08:00:00 2016-03-27 10:10:38 2016-03-29 04:10:38 18
Output for 5.6.21
2016-05-02 16:19:25 2016-05-07 15:00:00 2016-05-09 08:00:00 2016-05-02 16:19:25 2016-05-04 10:19:25 18
Output for 5.6.20
2016-04-10 08:28:14 2016-04-16 15:00:00 2016-04-18 08:00:00 2016-04-10 08:28:14 2016-04-12 02:28:14 18
Output for 5.6.19
2016-03-08 05:41:11 2016-03-12 15:00:00 2016-03-14 08:00:00 2016-03-08 05:41:11 2016-03-09 23:41:11 18
Output for 5.6.18
2016-03-15 14:38:15 2016-03-19 15:00:00 2016-03-21 08:00:00 2016-03-15 14:38:15 2016-03-17 08:38:15 18
Output for 5.6.17
2016-03-20 02:10:44 2016-03-26 15:00:00 2016-03-28 08:00:00 2016-03-20 02:10:44 2016-03-21 20:10:44 18
Output for 5.6.16
2016-03-28 10:59:53 2016-04-02 15:00:00 2016-04-04 08:00:00 2016-03-28 10:59:53 2016-03-30 04:59:53 18
Output for 5.6.15
2016-03-29 11:49:10 2016-04-02 15:00:00 2016-04-04 08:00:00 2016-03-29 11:49:10 2016-03-31 05:49:10 18
Output for 5.6.14
2016-04-14 17:31:44 2016-04-16 15:00:00 2016-04-18 08:00:00 2016-04-14 17:31:44 2016-04-16 11:31:44 18
Output for 5.6.13
2016-04-15 18:10:49 2016-04-16 15:00:00 2016-04-18 08:00:00 2016-04-15 18:10:49 2016-04-17 12:10:49 18
Output for 5.6.12
2016-04-20 08:39:56 2016-04-23 15:00:00 2016-04-25 08:00:00 2016-04-20 08:39:56 2016-04-22 02:39:56 18
Output for 5.6.11
2016-04-24 15:06:04 2016-04-30 15:00:00 2016-05-02 08:00:00 2016-04-24 15:06:04 2016-04-26 09:06:04 18
Output for 5.6.10
2016-04-25 17:11:53 2016-04-30 15:00:00 2016-05-02 08:00:00 2016-04-25 17:11:53 2016-04-27 11:11:53 18
Output for 5.6.9
2016-04-27 22:37:57 2016-04-30 15:00:00 2016-05-02 08:00:00 2016-04-27 22:37:57 2016-04-29 16:37:57 18
Output for 5.6.8
2016-04-30 07:08:01 2016-04-30 15:00:00 2016-05-02 08:00:00 2016-04-30 07:08:01 2016-05-02 01:08:01 18
Output for 5.5.35
2016-05-23 02:18:50 2016-05-28 15:00:00 2016-05-30 08:00:00 2016-05-23 02:18:50 2016-05-24 20:18:50 18
Output for 5.5.34
2016-04-11 10:42:06 2016-04-16 15:00:00 2016-04-18 08:00:00 2016-04-11 10:42:06 2016-04-13 04:42:06 18
Output for 5.5.33
2016-03-09 08:40:03 2016-03-12 15:00:00 2016-03-14 08:00:00 2016-03-09 08:40:03 2016-03-11 02:40:03 18
Output for 5.5.32
2016-03-17 18:35:03 2016-03-19 15:00:00 2016-03-21 08:00:00 2016-03-17 18:35:03 2016-03-19 12:35:03 18
Output for 5.5.31
2016-03-21 05:19:40 2016-03-26 15:00:00 2016-03-28 08:00:00 2016-03-21 05:19:40 2016-03-22 23:19:40 18
Output for 5.5.30
2016-04-01 13:41:15 2016-04-02 15:00:00 2016-04-04 08:00:00 2016-04-01 13:41:15 2016-04-03 07:41:15 18
Output for 5.5.29
2016-04-17 08:28:36 2016-04-23 15:00:00 2016-04-25 08:00:00 2016-04-17 08:28:36 2016-04-19 02:28:36 18
Output for 5.5.28
2016-04-21 11:58:27 2016-04-23 15:00:00 2016-04-25 08:00:00 2016-04-21 11:58:27 2016-04-23 05:58:27 18
Output for 5.5.27
2016-04-22 13:36:56 2016-04-23 15:00:00 2016-04-25 08:00:00 2016-04-22 13:36:56 2016-04-24 07:36:56 18
Output for 5.5.26
2016-04-26 19:52:26 2016-04-30 15:00:00 2016-05-02 08:00:00 2016-04-26 19:52:26 2016-04-28 13:52:26 18
Output for 5.5.25
2016-04-29 03:18:04 2016-04-30 15:00:00 2016-05-02 08:00:00 2016-04-29 03:18:04 2016-04-30 21:18:04 18
Output for 5.5.24
2016-05-24 09:41:16 2016-05-28 15:00:00 2016-05-30 08:00:00 2016-05-24 09:41:16 2016-05-26 03:41:16 18
Output for 5.4.45
2016-01-06 13:14:35 2016-01-09 15:00:00 2016-01-11 08:00:00 Fatal error: Class 'DateTimeImmutable' not found in /in/cfRFp on line 13
Process exited with code 255.
Output for 5.4.44
2016-01-06 13:14:36 2016-01-09 15:00:00 2016-01-11 08:00:00 Fatal error: Class 'DateTimeImmutable' not found in /in/cfRFp on line 13
Process exited with code 255.
Output for 5.4.41 - 5.4.43
2016-01-06 13:14:37 2016-01-09 15:00:00 2016-01-11 08:00:00 Fatal error: Class 'DateTimeImmutable' not found in /in/cfRFp on line 13
Process exited with code 255.
Output for 5.4.39 - 5.4.40
2016-01-06 13:14:38 2016-01-09 15:00:00 2016-01-11 08:00:00 Fatal error: Class 'DateTimeImmutable' not found in /in/cfRFp on line 13
Process exited with code 255.
Output for 5.4.35 - 5.4.38
2016-01-06 13:14:39 2016-01-09 15:00:00 2016-01-11 08:00:00 Fatal error: Class 'DateTimeImmutable' not found in /in/cfRFp on line 13
Process exited with code 255.
Output for 5.3.29, 5.4.31 - 5.4.34
2016-01-06 13:14:40 2016-01-09 15:00:00 2016-01-11 08:00:00 Fatal error: Class 'DateTimeImmutable' not found in /in/cfRFp on line 13
Process exited with code 255.
Output for 5.4.25 - 5.4.30
2016-01-06 13:14:41 2016-01-09 15:00:00 2016-01-11 08:00:00 Fatal error: Class 'DateTimeImmutable' not found in /in/cfRFp on line 13
Process exited with code 255.
Output for 5.3.28, 5.4.21 - 5.4.24
2016-01-06 13:14:42 2016-01-09 15:00:00 2016-01-11 08:00:00 Fatal error: Class 'DateTimeImmutable' not found in /in/cfRFp on line 13
Process exited with code 255.
Output for 5.4.18 - 5.4.20
2016-01-06 13:14:43 2016-01-09 15:00:00 2016-01-11 08:00:00 Fatal error: Class 'DateTimeImmutable' not found in /in/cfRFp on line 13
Process exited with code 255.
Output for 5.3.25 - 5.3.27, 5.4.14 - 5.4.17
2016-01-06 13:14:44 2016-01-09 15:00:00 2016-01-11 08:00:00 Fatal error: Class 'DateTimeImmutable' not found in /in/cfRFp on line 13
Process exited with code 255.
Output for 5.3.21 - 5.3.24, 5.4.11 - 5.4.13
2016-01-06 13:14:45 2016-01-09 15:00:00 2016-01-11 08:00:00 Fatal error: Class 'DateTimeImmutable' not found in /in/cfRFp on line 13
Process exited with code 255.