0

I am quite confused on whether where to look for the solution on this one. I initially used DateTime::diff to this problem, however, the server this time has PHP version < 5.3.

I am calculating time difference,

$beyond= $_POST['beyond']; // 2012-01-07
$here= $_POST['here']; //2012-01-14
$interval = abs(strtotime($beyond) - strtotime($here));

The output of this is 604800, I want to output this into string with a value of +7 or simply 7.

Thanks.

hakre
  • 193,403
  • 52
  • 435
  • 836
planet x
  • 1,599
  • 5
  • 26
  • 44
  • I think you'll find this question useful: http://stackoverflow.com/questions/2690504/php-producing-relative-date-time-from-timestamps – Jonathan Jan 05 '12 at 17:35
  • 1
    Hey, if you're using my code, please see my edit! I changed `86000` to `86400` that is the correct num of seconds in a day. –  Jan 06 '12 at 11:30

1 Answers1

1

I think this can help you:

$beyond= "2012-01-07";
$here= "2012-01-15";
$interval = abs(strtotime($here) - strtotime($beyond));

$interval/= 86400;

echo round($interval);

Just get the time and divide for a day (86400 secunds in a day).

RiaD
  • 46,822
  • 11
  • 79
  • 123