0

I'm stuck at something maybe easy but I cannot find an solution of it. I try to count how many minutes have past since the time() integer is saved. Now my function looks like:

if ($time < $time + 60 * 60 ) {
    return ' not Older than 1 hour';
}

And I want something like:

if ($time < $time + 60 * 60 ) {
    return '21 minutes old';
}
TorrBallen
  • 99
  • 1
  • 1
  • 12
  • this will help you to solve your problem . http://stackoverflow.com/questions/16265942/php-get-time-difference-in-minutes – Ricky Aug 02 '14 at 12:33
  • Oh didn't know I could do it via DateTime() .. +1 for solid solution :) – TorrBallen Aug 02 '14 at 12:39
  • ya you can just by retrieving only current time unless of using date and time i just show you way that how you can brother. – Ricky Aug 02 '14 at 12:48

2 Answers2

0
if(time() - $time < 3600) {
    return 'not older than 1 hour';
}


return ((time() - $time) * 60)." minutes old";

I hope this helps.

Charlotte Dunois
  • 4,638
  • 2
  • 20
  • 39
0
if(time() - 3600 > $time){
    echo date('i', time() - $time) . ' Minutes old';
}

see the date function

Le_Morri
  • 1,619
  • 14
  • 18