Fatal error: Call to a member function diff() on a non-object when the object exists?
<p>Trying to get the difference between two DateTime objects.  With the below code, I can echo out the <code>$endSub</code> variable and get a string like <code>2012-5-26T00:00:00-04:00</code> which is exactly what I need.  However, I get the error in the title if I do not <code>exit()</code> the code on the <code>$interval =</code> line.  Can anyone see a reason this would occur?</p>

<pre><code>if ($todays_month &gt;= 6){
    $endSub = new DateTime(($startYear+1).'-5-'.$startDay);
}else{
    $endSub = new DateTime($startYear.'-5-'.$startDay);
}

echo $endSub-&gt;format(DATE_RFC3339);
exit();

$interval = $startSub-&gt;diff($endSub);
</code></pre>
