3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $now = new DateTime('now'); $date = new DateTime('2014-05-01'); // Total difference in days $total_days = date_diff($now, $date)->format('%a'); // Get weeks $weeks = floor($total_days / 7); // Get days $days = $total_days % 7; echo $weeks . ' weeks and ' . $days . ' days ago';
Output for 5.6.28, 7.0.14 - 7.1.0
3 weeks and 5 days ago
Output for 7.0.6
107 weeks and 2 days ago
Output for 7.0.5
100 weeks and 3 days ago
Output for 7.0.4
97 weeks and 0 days ago
Output for 7.0.3
98 weeks and 2 days ago
Output for 7.0.2
98 weeks and 6 days ago
Output for 7.0.1
99 weeks and 0 days ago
Output for 7.0.0
99 weeks and 3 days ago
Output for 5.5.30, hhvm-3.12.0
100 weeks and 1 days ago
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.6.21
104 weeks and 4 days ago
Output for 5.6.20
101 weeks and 3 days ago
Output for 5.6.19
96 weeks and 5 days ago
Output for 5.6.18
97 weeks and 5 days ago
Output for 5.6.17
98 weeks and 3 days ago
Output for 5.6.16
99 weeks and 4 days ago
Output for 5.6.15
99 weeks and 5 days ago
Output for 5.6.14
102 weeks and 0 days ago
Output for 5.6.13
102 weeks and 1 days ago
Output for 5.6.12
102 weeks and 6 days ago
Output for 5.6.11
103 weeks and 3 days ago
Output for 5.6.10
103 weeks and 4 days ago
Output for 5.6.9
103 weeks and 6 days ago
Output for 5.6.8
104 weeks and 2 days ago
Output for 5.5.35
107 weeks and 4 days ago
Output for 5.5.34
101 weeks and 4 days ago
Output for 5.5.33
96 weeks and 6 days ago
Output for 5.5.32
98 weeks and 0 days ago
Output for 5.5.31
98 weeks and 4 days ago
Output for 5.5.29
102 weeks and 3 days ago
Output for 5.5.28
103 weeks and 0 days ago
Output for 5.5.27
103 weeks and 1 days ago
Output for 5.5.26
103 weeks and 5 days ago
Output for 5.5.25
104 weeks and 1 days ago
Output for 5.5.24
107 weeks and 5 days ago
Output for 5.3.0 - 5.4.45
91 weeks and 0 days ago
Output for 5.2.0 - 5.2.17
Fatal error: Call to undefined function date_diff() in /in/PcXY0 on line 7
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/PcXY0 on line 3
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/PcXY0 on line 7
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_OBJECT_OPERATOR in /in/PcXY0 on line 7
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/PcXY0 on line 7
Process exited with code 255.