I'm using DateTime and diff to compute the difference in days between two dates as follows:
$data_inceput = '2013-10-01';
$data_sfarsit = '2013-10-31';
$date1 = new DateTime($data_inceput);
$date2 = new DateTime($data_sfarsit);
$nr_zile = $date2->diff($date1)->format("%a");
$nr_zile
comes out as 6015 for some reasons.
If I `var_dump($date2->diff($date1));
i get:
object(DateInterval)#6 (8) {
["y"] => int(0)
["m"] => int(0)
["d"] => int(30)
["h"] => int(0)
["i"] => int(0)
["s"] => int(0)
["invert"] => int(1)
["days"] => int(6015)
Any idea why it's behaving this way? I've also tried to set the timezone to UTC to each date individually and get the same result.
edit: I tested on the production server and it works great, the only problem is on local apache server but the php settings are basically identical between the two.