0

$myTime = "1311059513";
$now = time();
$timeDiff = ($now - $myTime)/60;

I'm trying to subtract $myTime from $now to get the difference and divide by 60 to get the minutes difference. For some reason I don't get minutes in $timeDiff.

NobodyNada
  • 7,529
  • 6
  • 44
  • 51
  • 1
    this has been answered here http://stackoverflow.com/questions/365191/how-to-get-time-difference-in-minutes-in-php – ianbarker Jul 19 '11 at 14:34
  • 3
    If you don't get minutes, what else do you get? Since `$myTime` is a number and not text, don't use quotation marks; just write `$myTime = 1311059513;`. – Ferdinand Beyer Jul 19 '11 at 14:35
  • Actually this is the time I get from the db and convert it to time with 'strtotime()' 2011-07-19 07:34:24 –  Jul 19 '11 at 14:41

1 Answers1

1

On: PHP 5.3.2-1ubuntu4.7 with Suhosin-Patch (cli) (built: Jan 12 2011 18:36:55)

I get:

$myTime = "1311059513";
$now = time();
$timeDiff = ($now - $myTime)/60;
echo $timeDiff; // 443.78333333333

What's the problem?

1311059513 corresponds to 2011-07-19T02:11:53-05:00
ran it at 2011-07-19T09:35:40-05:00

09:35:40 - 02:11:53 = 7hrs 23min 57s = 443min 57s = 443.7833...
Marc B
  • 356,200
  • 43
  • 426
  • 500