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'). 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;
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.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
2016-01-06 13:13:42 2016-01-09 15:00:00 2016-01-11 08:00:00 2016-01-06 13:13:42 2016-01-08 07:13:42 18
Output for 7.3.32 - 7.3.33, 8.0.13
2016-01-06 12:13:42 2016-01-09 15:00:00 2016-01-11 08:00:00 2016-01-06 12:13:42 2016-01-08 06:13:42 18
Output for 7.0.6
2016-05-21 19:43:08 2016-05-21 15:00:00 2016-05-23 08:00:00 Notice: Undefined property: DateInterval::$hours in /in/h0PZp on line 9 Error! Please contact administrator!2016-05-21 19:43:08 2016-05-23 13:43:08 18
Output for 7.0.5
2016-04-03 09:26:20 2016-04-09 15:00:00 2016-04-11 08:00:00 2016-04-03 09:26:20 2016-04-05 03:26:20 18
Output for 7.0.4
2016-03-10 21:32:51 2016-03-12 15:00:00 2016-03-14 08:00:00 2016-03-10 21:32:51 2016-03-12 15:32:51 18
Output for 7.0.3
2016-03-18 22:57:07 2016-03-19 15:00:00 2016-03-21 08:00:00 2016-03-18 22:57:07 2016-03-20 16:57:07 18
Output for 7.0.2
2016-03-23 05:10:20 2016-03-26 15:00:00 2016-03-28 08:00:00 2016-03-23 05:10:20 2016-03-24 23:10:20 18
Output for 7.0.1
2016-03-24 08:17:18 2016-03-26 15:00:00 2016-03-28 08:00:00 2016-03-24 08:17:18 2016-03-26 02:17:18 18
Output for 7.0.0
2016-03-27 10:10:37 2016-04-02 15:00:00 2016-04-04 08:00:00 2016-03-27 10:10:37 2016-03-29 04:10:37 18
Output for 5.6.21
2016-05-02 21:38:59 2016-05-07 15:00:00 2016-05-09 08:00:00 2016-05-02 21:38:59 2016-05-04 15:38:59 18
Output for 5.6.20
2016-04-10 13:25:00 2016-04-16 15:00:00 2016-04-18 08:00:00 2016-04-10 13:25:00 2016-04-12 07:25:00 18
Output for 5.6.19
2016-03-08 05:41:10 2016-03-12 15:00:00 2016-03-14 08:00:00 2016-03-08 05:41:10 2016-03-09 23:41:10 18
Output for 5.6.18
2016-03-15 14:38:14 2016-03-19 15:00:00 2016-03-21 08:00:00 2016-03-15 14:38:14 2016-03-17 08:38:14 18
Output for 5.6.17
2016-03-20 02:10:42 2016-03-26 15:00:00 2016-03-28 08:00:00 2016-03-20 02:10:42 2016-03-21 20:10:42 18
Output for 5.6.16
2016-03-28 10:59:51 2016-04-02 15:00:00 2016-04-04 08:00:00 2016-03-28 10:59:51 2016-03-30 04:59:51 18
Output for 5.6.15
2016-03-29 11:49:09 2016-04-02 15:00:00 2016-04-04 08:00:00 2016-03-29 11:49:09 2016-03-31 05:49:09 18
Output for 5.6.14
2016-04-14 20:57:29 2016-04-16 15:00:00 2016-04-18 08:00:00 2016-04-14 20:57:29 2016-04-16 14:57:29 18
Output for 5.6.13
2016-04-15 21:48:25 2016-04-16 15:00:00 2016-04-18 08:00:00 2016-04-15 21:48:25 2016-04-17 15:48:25 18
Output for 5.6.12
2016-04-20 12:51:02 2016-04-23 15:00:00 2016-04-25 08:00:00 2016-04-20 12:51:02 2016-04-22 06:51:02 18
Output for 5.6.11
2016-04-24 18:45:29 2016-04-30 15:00:00 2016-05-02 08:00:00 2016-04-24 18:45:29 2016-04-26 12:45:29 18
Output for 5.6.10
2016-04-25 20:53:44 2016-04-30 15:00:00 2016-05-02 08:00:00 2016-04-25 20:53:44 2016-04-27 14:53:44 18
Output for 5.6.9
2016-04-28 02:52:09 2016-04-30 15:00:00 2016-05-02 08:00:00 2016-04-28 02:52:09 2016-04-29 20:52:09 18
Output for 5.6.8
2016-04-30 10:38:18 2016-04-30 15:00:00 2016-05-02 08:00:00 2016-04-30 10:38:18 2016-05-02 04:38:18 18
Output for 5.5.35
2016-05-23 11:02:54 2016-05-28 15:00:00 2016-05-30 08:00:00 2016-05-23 11:02:54 2016-05-25 05:02:54 18
Output for 5.5.34
2016-04-11 15:41:54 2016-04-16 15:00:00 2016-04-18 08:00:00 2016-04-11 15:41:54 2016-04-13 09:41:54 18
Output for 5.5.33
2016-03-09 08:40:02 2016-03-12 15:00:00 2016-03-14 08:00:00 2016-03-09 08:40:02 2016-03-11 02:40:02 18
Output for 5.5.32
2016-03-17 18:35:02 2016-03-19 15:00:00 2016-03-21 08:00:00 2016-03-17 18:35:02 2016-03-19 12:35:02 18
Output for 5.5.31
2016-03-21 05:19:38 2016-03-26 15:00:00 2016-03-28 08:00:00 2016-03-21 05:19:38 2016-03-22 23:19:38 18
Output for 5.5.30
2016-04-01 13:41:14 2016-04-02 15:00:00 2016-04-04 08:00:00 2016-04-01 13:41:14 2016-04-03 07:41:14 18
Output for 5.5.29
2016-04-17 11:58:10 2016-04-23 15:00:00 2016-04-25 08:00:00 2016-04-17 11:58:10 2016-04-19 05:58:10 18
Output for 5.5.28
2016-04-21 15:40:01 2016-04-23 15:00:00 2016-04-25 08:00:00 2016-04-21 15:40:01 2016-04-23 09:40:01 18
Output for 5.5.27
2016-04-22 17:11:09 2016-04-23 15:00:00 2016-04-25 08:00:00 2016-04-22 17:11:09 2016-04-24 11:11:09 18
Output for 5.5.26
2016-04-26 23:35:18 2016-04-30 15:00:00 2016-05-02 08:00:00 2016-04-26 23:35:18 2016-04-28 17:35:18 18
Output for 5.5.25
2016-04-29 07:10:22 2016-04-30 15:00:00 2016-05-02 08:00:00 2016-04-29 07:10:22 2016-05-01 01:10:22 18
Output for 5.5.24
2016-05-24 14:17:24 2016-05-28 15:00:00 2016-05-30 08:00:00 2016-05-24 14:17:24 2016-05-26 08:17:24 18

preferences:
218.31 ms | 401 KiB | 179 Q