3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $now = new DateTime('2016-01-10 23:30:59'); $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) { echo 'Error! Please contact administrator!'; } if (true) { $diff = strtotime($departure->format('Y-m-d H:i:s')) - strtotime($now->format('Y-m-d H:i:s')); echo $diff/3600; }
based on H6l3q
Output for 5.3.21 - 5.4.45, 5.6.28, 7.0.20 - 7.2.0
2016-01-10 23:30:59 2016-01-09 15:00:00 2016-01-11 08:00:00 Error! Please contact administrator!24
Output for 7.0.6
2016-01-10 23:30:59 2016-05-21 15:00:00 2016-05-23 08:00:00 24
Output for 7.0.5
2016-01-10 23:30:59 2016-04-09 15:00:00 2016-04-11 08:00:00 24
Output for 5.5.33, 5.6.19, 7.0.4
2016-01-10 23:30:59 2016-03-12 15:00:00 2016-03-14 08:00:00 24
Output for 5.5.32, 5.6.18, 7.0.3
2016-01-10 23:30:59 2016-03-19 15:00:00 2016-03-21 08:00:00 24
Output for 5.5.31, 5.6.17, 7.0.1 - 7.0.2
2016-01-10 23:30:59 2016-03-26 15:00:00 2016-03-28 08:00:00 24
Output for 5.5.30, 5.6.15 - 5.6.16, 7.0.0
2016-01-10 23:30:59 2016-04-02 15:00:00 2016-04-04 08:00:00 24
Output for 5.6.21
2016-01-10 23:30:59 2016-05-07 15:00:00 2016-05-09 08:00:00 24
Output for 5.5.34, 5.6.13 - 5.6.14, 5.6.20
2016-01-10 23:30:59 2016-04-16 15:00:00 2016-04-18 08:00:00 24
Output for 5.5.27 - 5.5.29, 5.6.12
2016-01-10 23:30:59 2016-04-23 15:00:00 2016-04-25 08:00:00 24
Output for 5.5.25 - 5.5.26, 5.6.8 - 5.6.11
2016-01-10 23:30:59 2016-04-30 15:00:00 2016-05-02 08:00:00 24
Output for 5.5.24, 5.5.35
2016-01-10 23:30:59 2016-05-28 15:00:00 2016-05-30 08:00:00 24