Jump to content

difference between 2 dates in terms of days


ajoo

Recommended Posts

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.

Link to comment
Share on other sites

It works fine here.

 

Have you done a var_dump at each stage of processing to see if something's funky?

 

<?php
 
/* Uncomment each commented line in turn and see what's up. */
 
$date1 =date_create("2013-12-07");
//var_dump($date1);exit;
$date2 = date("Y-m-d");
$date2 = date_create("$date2");
//var_dump($date2);exit;
echo "<br>";
$Gap = date_diff($date1, $date2);
//var_dump($Gap);exit;
echo $Gap->format("%a days");

 

Also, what system are you on?

Edited by dalecosp
Link to comment
Share on other sites

From the bugs webpage I quoted, I found this at the bottom :

 

"it's a bug affecting VC6 builds only. If you are affected just get VC9 builds from http://windows.php.net/download/ - you will also most likely need a VC9 or VC10 build of Apache from http://www.apachelounge.com/download/

VC6 is very old, outdated and not supported anymore, it's easy enough and free to upgrade to newer builds"

 

So it looks like it affects some builds and not others  :confused:    It's not a function I use myself, I use my own version of the function which I poached off the php website a loooong time ago  ;D

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.