Jump to content

Checking if timestamp is > 2 minutes old...


cgm225

Recommended Posts

<?php

function ChceckTime($time, $mins) {
  $stamp = strtotime($time);
  $mins = ($mins * 60);

    if((time() - $stamp) > $mins) return false;
      else return true;

}

  if(CheckTime($mystamp, 2)) echo'Dude its fine. Not greater than 2 mins.';
    else echo'Danger Will Robinson! Danger!!!';

?>

The following does not work for me...

 

 

$time = $this->data[$id]['timestamp'];  //Variable with timestamp in this format:  2008-09-11 14:11:30
$mins = 2;
     
$stamp = strtotime($time);
$mins = ($mins * 60);

if((time() - $stamp) > $mins) {
    echo 'Dude its fine. Not greater than 2 mins.';
} else {
    echo 'Danger Will Robinson! Danger!!!';
}

 

What am I doing wrong?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.