Reputation: 25711
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?
Upvotes: 5
Views: 921
Reputation: 4145
It seem a locale problem. hev you set the timezone in php.ini?
[Date]
date.timezone = Europe/Rome
Europe/Rome is my timezone ;)
or you can also add
ini_set("date.timezone","Europe/Rome");
in your code
Upvotes: 0
Reputation: 9148
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.
Upvotes: 5