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').'\n\n'; 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 vjCFu
Output for 5.6.28, 7.0.14 - 7.1.0
Now:18:10:20\n\n18:10:07 Not Old Enough 17:10:20 Not Old Enough 16:10:20 Not Old Enough 16:10:20 Old enough
Output for 7.0.6
Now:10:5:04\n\n10:5:51 Not Old Enough 10:5:04 Not Old Enough 08:5:04 Not Old Enough 08:5:04 Old enough
Output for 7.0.5
Now:23:4:56\n\n23:4:43 Not Old Enough 22:4:56 Not Old Enough 21:4:56 Not Old Enough 21:4:56 Old enough
Output for 7.0.4
Now:09:3:36\n\n09:3:23 Not Old Enough 09:3:36 Not Old Enough 08:3:36 Not Old Enough 07:3:36 Old enough
Output for 7.0.3
Now:10:3:39\n\n10:3:26 Not Old Enough 10:3:39 Not Old Enough 08:3:39 Not Old Enough 08:3:39 Old enough
Output for 7.0.2
Now:16:3:09\n\n16:3:56 Not Old Enough 16:3:09 Not Old Enough 14:3:09 Not Old Enough 14:3:09 Old enough
Output for 7.0.1
Now:21:3:18\n\n21:3:05 Not Old Enough 20:3:18 Not Old Enough 19:3:18 Not Old Enough 18:3:18 Old enough
Output for 7.0.0
Now:22:3:33\n\n22:3:20 Not Old Enough 22:3:33 Not Old Enough 20:3:33 Not Old Enough 20:3:33 Old enough
Output for 5.6.21
Now:05:5:25\n\n05:5:12 Not Old Enough 05:5:25 Not Old Enough 04:5:25 Not Old Enough 03:5:25 Old enough
Output for 5.6.20
Now:22:4:36\n\n22:4:23 Not Old Enough 21:4:36 Not Old Enough 20:4:36 Not Old Enough 20:4:36 Old enough
Output for 5.6.19
Now:17:3:56\n\n17:3:43 Not Old Enough 17:3:56 Not Old Enough 16:3:56 Not Old Enough 15:3:56 Old enough
Output for 5.6.18
Now:02:3:43\n\n02:3:30 Not Old Enough 01:3:43 Not Old Enough 00:3:43 Not Old Enough 23:3:43 Old enough
Output for 5.6.17
Now:14:3:14\n\n14:3:01 Not Old Enough 14:3:14 Not Old Enough 13:3:14 Not Old Enough 12:3:14 Old enough
Output for 5.6.16
Now:00:3:43\n\n00:3:30 Not Old Enough 00:3:43 Not Old Enough 22:3:43 Not Old Enough 22:3:43 Old enough
Output for 5.6.15
Now:01:3:00\n\n01:3:47 Not Old Enough 01:3:00 Not Old Enough 23:3:00 Not Old Enough 23:3:00 Old enough
Output for 5.6.14
Now:03:4:54\n\n03:4:41 Not Old Enough 03:4:54 Not Old Enough 02:4:54 Not Old Enough 01:4:54 Old enough
Output for 5.6.13
Now:07:4:21\n\n07:4:08 Not Old Enough 07:4:21 Not Old Enough 06:4:21 Not Old Enough 05:4:21 Old enough
Output for 5.6.12
Now:21:4:48\n\n21:4:35 Not Old Enough 21:4:48 Not Old Enough 19:4:48 Not Old Enough 19:4:48 Old enough
Output for 5.6.11
Now:04:4:46\n\n04:4:33 Not Old Enough 04:4:46 Not Old Enough 02:4:46 Not Old Enough 02:4:46 Old enough
Output for 5.6.10
Now:06:4:29\n\n06:4:16 Not Old Enough 06:4:29 Not Old Enough 04:4:29 Not Old Enough 04:4:29 Old enough
Output for 5.6.9
Now:11:4:40\n\n11:4:27 Not Old Enough 11:4:40 Not Old Enough 09:4:40 Not Old Enough 09:4:40 Old enough
Output for 5.6.8
Now:19:4:10\n\n19:4:57 Not Old Enough 19:4:10 Not Old Enough 17:4:10 Not Old Enough 17:4:10 Old enough
Output for 5.5.35
Now:09:5:08\n\n09:5:55 Not Old Enough 09:5:08 Not Old Enough 07:5:08 Not Old Enough 07:5:08 Old enough
Output for 5.5.34
Now:00:4:55\n\n00:4:42 Not Old Enough 00:4:55 Not Old Enough 22:4:55 Not Old Enough 22:4:55 Old enough
Output for 5.5.33
Now:20:3:51\n\n20:3:38 Not Old Enough 20:3:51 Not Old Enough 19:3:51 Not Old Enough 18:3:51 Old enough
Output for 5.5.32
Now:03:3:12\n\n03:3:59 Not Old Enough 03:3:12 Not Old Enough 01:3:12 Not Old Enough 01:3:12 Old enough
Output for 5.5.31
Now:17:3:25\n\n17:3:12 Not Old Enough 17:3:25 Not Old Enough 15:3:25 Not Old Enough 15:3:25 Old enough
Output for 5.5.30
Now:03:4:45\n\n03:4:32 Not Old Enough 03:4:45 Not Old Enough 01:4:45 Not Old Enough 01:4:45 Old enough
Output for 5.5.29
Now:21:4:36\n\n21:4:23 Not Old Enough 21:4:36 Not Old Enough 20:4:36 Not Old Enough 19:4:36 Old enough
Output for 5.5.28
Now:00:4:01\n\n00:4:48 Not Old Enough 00:4:01 Not Old Enough 23:4:01 Not Old Enough 22:4:01 Old enough
Output for 5.5.27
Now:03:4:44\n\n03:4:31 Not Old Enough 02:4:44 Not Old Enough 01:4:44 Not Old Enough 00:4:44 Old enough
Output for 5.5.26
Now:08:4:16\n\n08:4:03 Not Old Enough 08:4:16 Not Old Enough 07:4:16 Not Old Enough 06:4:16 Old enough
Output for 5.5.25
Now:15:4:52\n\n15:4:39 Not Old Enough 14:4:52 Not Old Enough 13:4:52 Not Old Enough 12:4:52 Old enough
Output for 5.5.24
Now:22:5:06\n\n22:5:53 Not Old Enough 22:5:06 Not Old Enough 20:5:06 Not Old Enough 20:5:06 Old enough
Output for 5.4.45
Now:15:9:58\n\n15: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:54\n\n15: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:48\n\n15: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:07\n\n09:7:54 Not Old Enough 09:7:07 Not Old Enough 07:7:07 Not Old Enough 07:7:07 Old enough
Output for 5.4.41
Now:09:7:05\n\n09:7:52 Not Old Enough 09:7:05 Not Old Enough 07:7:05 Not Old Enough 07:7:05 Old enough
Output for 5.4.40
Now:09:7:01\n\n09:7:48 Not Old Enough 09:7:01 Not Old Enough 07:7:01 Not Old Enough 07:7:01 Old enough
Output for 5.4.39
Now:09:7:00\n\n09:7:47 Not Old Enough 09:7:00 Not Old Enough 07:7:00 Not Old Enough 07:7:00 Old enough
Output for 5.4.38
Now:09:7:59\n\n09:7:46 Not Old Enough 09:7:59 Not Old Enough 07:7:59 Not Old Enough 07:7:59 Old enough
Output for 5.4.35 - 5.4.37
Now:09:7:56\n\n09:7:43 Not Old Enough 09:7:56 Not Old Enough 07:7:56 Not Old Enough 07:7:56 Old enough
Output for 5.4.34
Now:09:7:55\n\n09:7:42 Not Old Enough 09:7:55 Not Old Enough 07:7:55 Not Old Enough 07:7:55 Old enough
Output for 5.4.29 - 5.4.32
Now:18:10:24\n\n18:10:11 Not Old Enough 17:10:24 Not Old Enough 16:10:24 Not Old Enough 16:10:24 Old enough
Output for 5.4.7 - 5.4.28
Now:18:10:25\n\n18:10:12 Not Old Enough 17:10:25 Not Old Enough 16:10:25 Not Old Enough 16:10:25 Old enough
Output for 5.3.16 - 5.4.6
Now:18:10:26\n\n18:10:13 Not Old Enough 17:10:26 Not Old Enough 16:10:26 Not Old Enough 16:10:26 Old enough
Output for 5.3.0 - 5.3.15
Now:18:10:27\n\n18:10:14 Not Old Enough 17:10:27 Not Old Enough 16:10:27 Not Old Enough 16:10:27 Old enough
Output for 5.2.11 - 5.2.17
Now:18:10:27\n\n Fatal error: Call to undefined method DateTime::getTimestamp() in /in/8jkB8 on line 3
Process exited with code 255.
Output for 5.2.0 - 5.2.10
Now:18:10:28\n\n Fatal error: Call to undefined method DateTime::getTimestamp() in /in/8jkB8 on line 3
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Fatal error: Class 'Datetime' not found in /in/8jkB8 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/8jkB8 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/8jkB8 on line 10