PHP5.3 number_format返回NaN

I have this piece code developed in PHP5.5 without any issue. However, when same code is moved to another server in PHP5.3, the number_format() does not return expected value, but return "nan"

This is my code:

number_format($num, 2, ".", ",");

the variable $num is retrieved from database with data type decimal(25,8)

What confuse me is that it works for some number, but not some others. Example:

$num = 1800.00000000
number_format($num, 2, ".", ",") ==> returns "nan"

$num = 1000.00000000
number_format($num, 2, ".", ",") ==> returns "1,000.00"

Is this a common bug in PHP 5.3? Is there any solution for it?

I have google but there is no solution that works for my case so far. The typecast to float or floatval() also not working.

UPDATE

The issue happen because of DateTime::diff() that is run just before the number_format line.

Somehow this function causes issue in PHP5.3 but not in PHP5.5

Once the function is changed by using strtotime() to calculate the difference between 2 dates, everything works normal.

Although, truthfully, i still don't know why the issue happen in the first place. If anyone know about this, please share with me too. Thanks!