I got the same 6015 days in PHP 5.3.0 and found a solution using var_dump() . My exact code is here:
$timestring = "Thu, 13 Jun 2013 14:05:59 GMT"; date_default_timezone_set('GMT'); $date = DateTime::createFromFormat('D, d MYG:i:s T', $timeString); $nowdate = new DateTime("now"); $interval = $date->diff($nowdate);
Now, if I do a var_dump($interval) , the result is:
object(DateInterval)#5 (8) { ["y"]=> int(0) ["m"]=> int(0) ["d"]=> int(0) ["h"]=> int(19) ["i"]=> int(45) ["s"]=> int(33) ["invert"]=> int(0) ["days"]=> int(6015) }
So, hours ( h ), minutes ( i ) and seconds ( s ) are set correctly, but there is another days property that remains constant at block 6015, and this is what others get as an error. Well, I canβt understand where he gets this value. Again, according to the PHP manual for DateInterval at http://www.php.net/manual/en/class.dateinterval.php , I tried to access them as object properties, and everything went fine.
Therefore, I get the exact result:
echo (string) $interval->d." days ago";
Zeeshan
source share