I have the following code fragment:
$now = '2011-12-01 22:32:33';
$datetime = '2011-12-01 00:07:27';
$nowObj = new DateTime($now);
$datetimeObj = new DateTime($datetime);
$diff = $datetimeObj->diff($nowObj); //leaving this in screws up the next line
number_format(1134); //this becomes NaN
When I am running through this code and leave the $diff = ... line in, it messes with other numbers and math that I do later in the code. For instance, my number_format(1134); later on becomes NaN. I am using a XAMPP stack with PHP 5.3.1. Is this a bug?
Could this be related, hmm ...
If you are on windows, I would make sure time zone settings are set correctly. The comments on php.net point out a couple of quirks and buggy behavior under windows, maybe seriously consider using an alternate method for diffing your dates if issues persist.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With