3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $list['timeadded'] = '01/02/2012 07:40:23'; $dt1 = new DateTime($list['timeadded']); $dt2 = new DateTime(); $dt2->sub(new DateInterval('P7D')); $interval = $dt1->diff($dt2); echo $interval->d; if ($interval->d <= 7) { echo $interval->format('%d days'); }
Output for 5.6.15, 5.6.28, 7.0.12 - 7.1.0
19
Output for 5.6.14, 7.0.6
23
Output for 7.0.5
24
Output for 5.6.20, 7.0.4
00 days
Output for 7.0.3
8
Output for 5.5.27, 5.5.35, 7.0.2
12
Output for 7.0.1
14
Output for 5.6.9, 7.0.0
17
Output for 5.5.30, 5.6.21
22
Output for 5.6.19
26
Output for 5.6.13, 5.6.18
55 days
Output for 5.3.3 - 5.4.45, 5.6.17
9
Output for 5.5.25, 5.6.16
18
Output for 5.5.31, 5.6.12
10
Output for 5.6.11
13
Output for 5.6.7, 5.6.10
15
Output for 5.6.8
20
Output for 5.5.34
11 days
Output for 5.5.33
28
Output for 5.5.32
66 days
Output for 5.5.29
77 days
Output for 5.5.28
11
Output for 5.5.26
16
Output for 5.5.24
21
Output for 5.3.0 - 5.3.2
22 days
Output for 5.2.0 - 5.2.17
Fatal error: Call to undefined method DateTime::sub() in /in/f0dmW on line 7
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/f0dmW on line 4
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: datetime in /in/f0dmW on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: datetime in /in/f0dmW on line 4