php_developer Posted May 16, 2013 Share Posted May 16, 2013 Hello, I am working with date_diff($date1,$date2) function but it is not giving me correct result... I have copied and pasted the following code:<?php$date1=date_create("2013-03-15");$date2=date_create("2013-12-12");$diff=date_diff($date1,$date2);echo $diff->format("%R%a days");?>from : http://www.w3schools.com/php/showphp.asp?filename=demo_func_date_diff but it is not giving me the same result ("+272 days") as the above refference says(shows), rather it gives me "+6015 days", which is wrong. Please let me know, am i going wrong... or is there any other problem Link to comment Share on other sites More sharing options...
Ingolme Posted May 16, 2013 Share Posted May 16, 2013 I copied your code and tested it and it's giving me the correct result. Link to comment Share on other sites More sharing options...
php_developer Posted May 16, 2013 Author Share Posted May 16, 2013 But I am not getting the correct result. Not even for the following code:<?php$datetime1 = date_create('2009-10-11');$datetime2 = date_create('2009-10-13');$interval = date_diff($datetime1, $datetime2);echo $interval->format('%R%a days');?> Do I need to change some date setting at my desktop or is there any php version issue...? Please let me know.. Link to comment Share on other sites More sharing options...
Ingolme Posted May 16, 2013 Share Posted May 16, 2013 I can't think of anything that would cause it to behave like that.What version of PHP are you using? Link to comment Share on other sites More sharing options...
php_developer Posted May 17, 2013 Author Share Posted May 17, 2013 Its 5.3.5(xampp)..I realy don't know why is this function not giving me correct result at my localhost.What ever date I am putting in this function, it gives me same result as, "+6015 days". But will it work correctly online (at server, there may be an issue at my localhost)...? Link to comment Share on other sites More sharing options...
justsomeguy Posted May 17, 2013 Share Posted May 17, 2013 https://bugs.php.net/bug.php?id=51184 The solution is to upgrade from a VC6 build of PHP to a VC9 build, it only exists in VC6 builds for Windows. Link to comment Share on other sites More sharing options...
php_developer Posted May 18, 2013 Author Share Posted May 18, 2013 Okay, Now I got the reason... Thank You so much, for Your Support... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now