Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

difference between 2 dates in terms of days

$
0
0

Hi to all !

 

While i await some reply to my earlier query, here's another one - a simpler one perhaps but it has me baffled.

 The following is the code I tested on phpfiddle and it works great. Gives the correct time difference in  days. 

<?php
$date1 =date_create("2013-12-07");
$date2 = date("Y-m-d");
$date2 = date_create("$date2");
echo "<br>";
$Gap = date_diff($date1, $date2);
echo $Gap->format("%a days");
?>

However when i actually implement it on my localhost running version 5.3 of php i get the difference as a multiple of 6015. So if there is a 1 day difference, instead of getting 1, i get 6015. for 3 days i got 18045 which is 6015 * 3. I have tried but i am unable to figure it out.  Any suggestions anyone. 

 

Thanks.


Viewing all articles
Browse latest Browse all 13200

Trending Articles