3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function check($dateAdded,$now){ $secondsInPast = $now->getTimestamp() - $dateAdded->getTimestamp(); if($secondsInPast > 60*60*2){ echo $dateAdded->format('H:n:s'). " Old enough\n"; } else { echo $dateAdded->format('H:n:s'). " Not Old Enough\n"; } } $now = new Datetime('now'); echo "Now:" . $now->format('H:n:s'); check(new DateTime('- 13 seconds'),$now); check(new DateTime('- 13 minutes'),$now); check(new DateTime('- 100 minutes'),$now); check(new DateTime('- 125 minutes'),$now);
based on Kp57s
Output for 5.6.28, 7.0.14 - 7.1.0
Now:18:10:1018:10:57 Not Old Enough 17:10:10 Not Old Enough 16:10:10 Not Old Enough 16:10:10 Old enough
Output for 7.0.6
Now:10:5:0110:5:48 Not Old Enough 10:5:01 Not Old Enough 08:5:01 Not Old Enough 08:5:01 Old enough
Output for 7.0.5
Now:23:4:5223:4:39 Not Old Enough 22:4:52 Not Old Enough 21:4:52 Not Old Enough 21:4:52 Old enough
Output for 7.0.4
Now:09:3:3209:3:19 Not Old Enough 09:3:32 Not Old Enough 08:3:32 Not Old Enough 07:3:32 Old enough
Output for 7.0.3
Now:10:3:3410:3:21 Not Old Enough 10:3:34 Not Old Enough 08:3:34 Not Old Enough 08:3:34 Old enough
Output for 7.0.2
Now:16:3:0516:3:52 Not Old Enough 16:3:05 Not Old Enough 14:3:05 Not Old Enough 14:3:05 Old enough
Output for 7.0.1
Now:21:3:1421:3:01 Not Old Enough 20:3:14 Not Old Enough 19:3:14 Not Old Enough 18:3:14 Old enough
Output for 7.0.0
Now:22:3:2922:3:16 Not Old Enough 22:3:29 Not Old Enough 20:3:29 Not Old Enough 20:3:29 Old enough
Output for hhvm-3.12.0
Now:13:3:3613:3:23 Not Old Enough 13:3:36 Not Old Enough 11:3:36 Not Old Enough 11:3:36 Old enough
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.6.21
Now:05:5:2105:5:08 Not Old Enough 05:5:21 Not Old Enough 04:5:21 Not Old Enough 03:5:21 Old enough
Output for 5.6.20
Now:22:4:3322:4:20 Not Old Enough 21:4:33 Not Old Enough 20:4:33 Not Old Enough 20:4:33 Old enough
Output for 5.6.19
Now:17:3:5117:3:38 Not Old Enough 17:3:51 Not Old Enough 16:3:51 Not Old Enough 15:3:51 Old enough
Output for 5.6.18
Now:02:3:3802:3:25 Not Old Enough 01:3:38 Not Old Enough 00:3:38 Not Old Enough 23:3:38 Old enough
Output for 5.6.17
Now:14:3:0914:3:56 Not Old Enough 14:3:09 Not Old Enough 13:3:09 Not Old Enough 12:3:09 Old enough
Output for 5.6.16
Now:00:3:3900:3:26 Not Old Enough 00:3:39 Not Old Enough 22:3:39 Not Old Enough 22:3:39 Old enough
Output for 5.6.15
Now:01:3:5601:3:43 Not Old Enough 01:3:56 Not Old Enough 23:3:56 Not Old Enough 23:3:56 Old enough
Output for 5.6.14
Now:03:4:5003:4:37 Not Old Enough 03:4:50 Not Old Enough 02:4:50 Not Old Enough 01:4:50 Old enough
Output for 5.6.13
Now:07:4:1707:4:04 Not Old Enough 07:4:17 Not Old Enough 06:4:17 Not Old Enough 05:4:17 Old enough
Output for 5.6.12
Now:21:4:4421:4:31 Not Old Enough 21:4:44 Not Old Enough 19:4:44 Not Old Enough 19:4:44 Old enough
Output for 5.6.11
Now:04:4:4204:4:29 Not Old Enough 04:4:42 Not Old Enough 02:4:42 Not Old Enough 02:4:42 Old enough
Output for 5.6.10
Now:06:4:2606:4:13 Not Old Enough 06:4:26 Not Old Enough 04:4:26 Not Old Enough 04:4:26 Old enough
Output for 5.6.9
Now:11:4:3611:4:23 Not Old Enough 11:4:36 Not Old Enough 09:4:36 Not Old Enough 09:4:36 Old enough
Output for 5.6.8
Now:19:4:0619:4:53 Not Old Enough 19:4:06 Not Old Enough 17:4:06 Not Old Enough 17:4:06 Old enough
Output for 5.5.35
Now:09:5:0509:5:52 Not Old Enough 09:5:05 Not Old Enough 07:5:05 Not Old Enough 07:5:05 Old enough
Output for 5.5.34
Now:00:4:5100:4:38 Not Old Enough 00:4:51 Not Old Enough 22:4:51 Not Old Enough 22:4:51 Old enough
Output for 5.5.33
Now:20:3:4620:3:33 Not Old Enough 20:3:46 Not Old Enough 19:3:46 Not Old Enough 18:3:46 Old enough
Output for 5.5.32
Now:03:3:0603:3:53 Not Old Enough 03:3:06 Not Old Enough 01:3:06 Not Old Enough 01:3:06 Old enough
Output for 5.5.31
Now:17:3:2117:3:08 Not Old Enough 17:3:21 Not Old Enough 15:3:21 Not Old Enough 15:3:21 Old enough
Output for 5.5.30
Now:03:4:4103:4:28 Not Old Enough 03:4:41 Not Old Enough 01:4:41 Not Old Enough 01:4:41 Old enough
Output for 5.5.29
Now:21:4:3321:4:20 Not Old Enough 21:4:33 Not Old Enough 20:4:33 Not Old Enough 19:4:33 Old enough
Output for 5.5.28
Now:00:4:5700:4:44 Not Old Enough 00:4:57 Not Old Enough 23:4:57 Not Old Enough 22:4:57 Old enough
Output for 5.5.27
Now:03:4:4003:4:27 Not Old Enough 02:4:40 Not Old Enough 01:4:40 Not Old Enough 00:4:40 Old enough
Output for 5.5.26
Now:08:4:1208:4:59 Not Old Enough 08:4:12 Not Old Enough 07:4:12 Not Old Enough 06:4:12 Old enough
Output for 5.5.25
Now:15:4:4715:4:34 Not Old Enough 14:4:47 Not Old Enough 13:4:47 Not Old Enough 12:4:47 Old enough
Output for 5.5.24
Now:22:5:0422:5:51 Not Old Enough 22:5:04 Not Old Enough 20:5:04 Not Old Enough 20:5:04 Old enough
Output for 5.4.45
Now:15:9:5815:9:45 Not Old Enough 14:9:58 Not Old Enough 13:9:58 Not Old Enough 12:9:58 Old enough
Output for 5.4.44
Now:15:9:5415:9:41 Not Old Enough 14:9:54 Not Old Enough 13:9:54 Not Old Enough 12:9:54 Old enough
Output for 5.4.43
Now:15:9:4815:9:35 Not Old Enough 14:9:48 Not Old Enough 13:9:48 Not Old Enough 12:9:48 Old enough
Output for 5.4.42
Now:09:7:2709:7:14 Not Old Enough 09:7:27 Not Old Enough 07:7:27 Not Old Enough 07:7:27 Old enough
Output for 5.4.41
Now:09:7:2609:7:13 Not Old Enough 09:7:26 Not Old Enough 07:7:26 Not Old Enough 07:7:26 Old enough
Output for 5.4.39 - 5.4.40
Now:09:7:2109:7:08 Not Old Enough 09:7:21 Not Old Enough 07:7:21 Not Old Enough 07:7:21 Old enough
Output for 5.4.38
Now:09:7:2009:7:07 Not Old Enough 09:7:20 Not Old Enough 07:7:20 Not Old Enough 07:7:20 Old enough
Output for 5.4.37
Now:09:7:1809:7:05 Not Old Enough 09:7:18 Not Old Enough 07:7:18 Not Old Enough 07:7:18 Old enough
Output for 5.4.34 - 5.4.36
Now:09:7:1709:7:04 Not Old Enough 09:7:17 Not Old Enough 07:7:17 Not Old Enough 07:7:17 Old enough
Output for 5.4.27 - 5.4.32
Now:18:10:1418:10:01 Not Old Enough 17:10:14 Not Old Enough 16:10:14 Not Old Enough 16:10:14 Old enough
Output for 5.4.6 - 5.4.26
Now:18:10:1518:10:02 Not Old Enough 17:10:15 Not Old Enough 16:10:15 Not Old Enough 16:10:15 Old enough
Output for 5.3.15 - 5.4.5
Now:18:10:1618:10:03 Not Old Enough 17:10:16 Not Old Enough 16:10:16 Not Old Enough 16:10:16 Old enough
Output for 5.3.0 - 5.3.14
Now:18:10:1718:10:04 Not Old Enough 17:10:17 Not Old Enough 16:10:17 Not Old Enough 16:10:17 Old enough
Output for 5.2.10 - 5.2.17
Now:18:10:17 Fatal error: Call to undefined method DateTime::getTimestamp() in /in/vjCFu on line 3
Process exited with code 255.
Output for 5.2.0 - 5.2.9
Now:18:10:18 Fatal error: Call to undefined method DateTime::getTimestamp() in /in/vjCFu on line 3
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Fatal error: Class 'Datetime' not found in /in/vjCFu on line 10
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: datetime in /in/vjCFu on line 10
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: datetime in /in/vjCFu on line 10