3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php // Query timestamp of entry //returns like this $entrydatetime = "2013-11-20 17:36:18"; //get current time $now = new \DateTime(); // Use DateTime on $entrydatetime $entrydatetime = new \DateTime($entrydatetime); // Seconds echo $now->getTimestamp() - $entrydatetime->getTimestamp() . "seconds\n"; // Human readable is more complex $age = $entrydatetime->diff($now); // DateInterval if ($age->years > 0) { echo $age->format('%y years ago'); } else if ($age->months > 0) { echo $age->format('%m months ago'); } else if ($age->days > 0) { echo $age->format('%a days ago'); } else { echo $age->format('%h hours, %i minutes ago'); }
Output for 5.6.28, 7.0.14 - 7.1.0
129573seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 1 days ago
Output for 7.0.6
77321062seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 894 days ago
Output for 7.0.5
74687690seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 864 days ago
Output for 7.0.4
72659472seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 840 days ago
Output for 7.0.3
73353334seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 848 days ago
Output for 7.0.2
73720930seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 853 days ago
Output for 7.0.1
73822400seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 854 days ago
Output for 7.0.0
74085020seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 857 days ago
Output for hhvm-3.12.0
72867093seconds Fatal error: Uncaught exception 'Exception' with message 'Undefined property 'years) on DateInterval object' in /in/MZfec:24 Stack trace: #0 /in/MZfec(24): DateInterval->__get() #1 {main}
Process exited with code 255.
Output for hhvm-3.10.0
74405222seconds Fatal error: Uncaught exception 'Exception' with message 'Undefined property 'years) on DateInterval object' in /in/MZfec:24 Stack trace: #0 /in/MZfec(24): DateInterval->__get() #1 {main}
Process exited with code 255.
Output for 5.6.21
77217270seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 893 days ago
Output for 5.6.20
75288780seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 871 days ago
Output for 5.6.19
72428337seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 838 days ago
Output for 5.6.18
73065059seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 845 days ago
Output for 5.6.17
73453442seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 850 days ago
Output for 5.6.16
74174280seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 858 days ago
Output for 5.6.15
74263747seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 859 days ago
Output for 5.6.14
74616358seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 863 days ago
Output for 5.6.13
75754954seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 876 days ago
Output for 5.6.12
76152522seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 881 days ago
Output for 5.6.11
76435171seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 884 days ago
Output for 5.6.10
76614881seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 886 days ago
Output for 5.6.9
76806152seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 889 days ago
Output for 5.6.8
77010422seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 891 days ago
Output for 5.5.35
78965791seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 913 days ago
Output for 5.5.34
75383216seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 872 days ago
Output for 5.5.33
72525564seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 839 days ago
Output for 5.5.32
73251223seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 847 days ago
Output for 5.5.31
73550120seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 851 days ago
Output for 5.5.30
74529767seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 862 days ago
Output for 5.5.29
75893207seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 878 days ago
Output for 5.5.28
76250385seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 882 days ago
Output for 5.5.27
76343694seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 883 days ago
Output for 5.5.26
76710945seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 887 days ago
Output for 5.5.25
76908248seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 890 days ago
Output for 5.5.24
79092584seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 915 days ago
Output for 5.4.45
62928961seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 728 days ago
Output for 5.4.44
62928962seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 728 days ago
Output for 5.4.43
62928963seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 728 days ago
Output for 5.4.41 - 5.4.42
62928964seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 728 days ago
Output for 5.4.39 - 5.4.40
62928965seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 728 days ago
Output for 5.4.37 - 5.4.38
62928966seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 728 days ago
Output for 5.4.35 - 5.4.36
62928967seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 728 days ago
Output for 5.3.29, 5.4.32 - 5.4.34
62928968seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 728 days ago
Output for 5.4.28 - 5.4.31
62928969seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 728 days ago
Output for 5.4.25 - 5.4.27
62928970seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 728 days ago
Output for 5.3.28, 5.4.23 - 5.4.24
62928971seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 728 days ago
Output for 5.4.19 - 5.4.22
62928972seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 728 days ago
Output for 5.3.26 - 5.3.27, 5.4.17 - 5.4.18
62928973seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 728 days ago
Output for 5.3.23 - 5.3.25, 5.4.13 - 5.4.16
62928974seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 728 days ago
Output for 5.3.20 - 5.3.22, 5.4.9 - 5.4.12
62928975seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 728 days ago
Output for 5.3.16 - 5.3.19, 5.4.6 - 5.4.8
62928976seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 728 days ago
Output for 5.3.12 - 5.3.15, 5.4.3 - 5.4.5
62928977seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 728 days ago
Output for 5.3.8 - 5.3.11, 5.4.0 - 5.4.2
62928978seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 728 days ago
Output for 5.3.6 - 5.3.7
62928979seconds Notice: Undefined property: DateInterval::$years in /in/MZfec on line 24 Notice: Undefined property: DateInterval::$months in /in/MZfec on line 26 728 days ago
Output for 5.3.3 - 5.3.5
62928979seconds Fatal error: main(): Unknown property (years) in /in/MZfec on line 24
Process exited with code 255.
Output for 5.3.0 - 5.3.2
62928980seconds Fatal error: main(): Unknown property (years) in /in/MZfec on line 24
Process exited with code 255.
Output for 5.2.0 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/MZfec on line 10 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/MZfec on line 13 Fatal error: Call to undefined method DateTime::getTimestamp() in /in/MZfec on line 17
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/MZfec on line 10 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/MZfec on line 13 Fatal error: Class 'DateTime' not found in /in/MZfec on line 10
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/MZfec on line 10 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/MZfec on line 13 Fatal error: Cannot instantiate non-existent class: datetime in /in/MZfec on line 10
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/MZfec on line 10 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/MZfec on line 13 Fatal error: Cannot instantiate non-existent class: datetime in /in/MZfec on line 10