3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $data = array( array(new DateTime(), new DateTime('2013-12-31')), array(new DateTime('2013-10-28'), new DateTime('2013-12-31')), ); foreach($data as $parameters) { var_dump(call_user_func_array('getDateDifferenceAsDays', $parameters)); var_dump(call_user_func_array('getDateDifferenceAsDays2', $parameters)); } function getDateDifferenceAsDays(\DateTime $dateStart, \DateTime $dateEnd) { $refDateStart = new \DateTime($dateStart->format('Y-m-d')); $refDateEnd = new \DateTime($dateEnd->format('Y-m-d')); $interval = $refDateStart->diff($refDateEnd); return (int)$interval->format('%R%a'); } function getDateDifferenceAsDays2(\DateTime $dateStart, \DateTime $dateEnd) { $refDateStart = clone $dateStart; $refDateEnd = clone $dateEnd; $interval = $refDateStart->diff($refDateEnd); return (int)$interval->format('%R%a'); } ?>
Output for 7.0.14 - 7.1.0
int(60) int(59) int(64) int(64)
Output for 7.0.6
int(-854) int(-854) int(64) int(64)
Output for 7.0.5
int(-823) int(-823) int(64) int(64)
Output for 7.0.4
int(-799) int(-799) int(64) int(64)
Output for 7.0.3
int(-808) int(-808) int(64) int(64)
Output for 7.0.2
int(-811) int(-811) int(64) int(64)
Output for 7.0.1
int(-813) int(-813) int(64) int(64)
Output for 7.0.0
int(-816) int(-816) int(64) int(64)
Output for 5.6.21
int(-852) int(-852) int(64) int(64)
Output for 5.6.20
int(-830) int(-830) int(64) int(64)
Output for 5.6.19
int(-796) int(-796) int(64) int(64)
Output for 5.6.18
int(-804) int(-804) int(64) int(64)
Output for 5.6.17
int(-809) int(-809) int(64) int(64)
Output for 5.6.16
int(-817) int(-817) int(64) int(64)
Output for 5.6.15
int(-818) int(-818) int(64) int(64)
Output for 5.6.14
int(-822) int(-822) int(64) int(64)
Output for 5.6.13
int(-835) int(-835) int(64) int(64)
Output for 5.6.12
int(-840) int(-840) int(64) int(64)
Output for 5.6.11
int(-843) int(-843) int(64) int(64)
Output for 5.6.10
int(-845) int(-845) int(64) int(64)
Output for 5.6.9
int(-848) int(-848) int(64) int(64)
Output for 5.6.8
int(-850) int(-850) int(64) int(64)
Output for 5.6.7
int(-875) int(-875) int(64) int(64)
Output for 5.5.35
int(-872) int(-872) int(64) int(64)
Output for 5.5.34
int(-831) int(-831) int(64) int(64)
Output for 5.5.33
int(-798) int(-798) int(64) int(64)
Output for 5.5.32
int(-805) int(-805) int(64) int(64)
Output for 5.5.31
int(-810) int(-810) int(64) int(64)
Output for 5.5.30
int(-821) int(-821) int(64) int(64)
Output for 5.5.29
int(-837) int(-837) int(64) int(64)
Output for 5.5.28
int(-841) int(-841) int(64) int(64)
Output for 5.5.27
int(-842) int(-842) int(64) int(64)
Output for 5.5.26
int(-846) int(-846) int(64) int(64)
Output for 5.5.25
int(-849) int(-849) int(64) int(64)
Output for 5.5.24
int(-851) int(-851) int(64) int(64)
Output for 5.3.0 - 5.4.45
int(-760) int(-760) int(64) int(64)
Output for 5.2.0 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/QmFSt on line 14 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/QmFSt on line 14 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/QmFSt on line 16 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/QmFSt on line 17 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/QmFSt on line 24 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/QmFSt on line 24 Fatal error: Call to undefined method DateTime::diff() in /in/QmFSt on line 19
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/QmFSt on line 14 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/QmFSt on line 14 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/QmFSt on line 16 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/QmFSt on line 17 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/QmFSt on line 24 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/QmFSt on line 24 Fatal error: Class 'DateTime' not found in /in/QmFSt on line 4
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/QmFSt on line 14 Parse error: syntax error, unexpected T_STRING, expecting ')' in /in/QmFSt on line 14
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/QmFSt on line 14 Parse error: parse error, unexpected T_STRING, expecting ')' in /in/QmFSt on line 14
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/QmFSt on line 14 Parse error: parse error, expecting `')'' in /in/QmFSt on line 14
Process exited with code 255.