Forum Moderators: coopster
$u = 1 //for testing
$result = mysql_query(" SELECT SessionID,
TIMEDIFF(now(),LastSessionUpdate)
FROM Sessions
WHERECustomerID = '".$u."'");
$res = mysql_fetch_row($result);
$match = $res[0];
$timediff = $res[1];
list($hrs, $mins, $secs) = split('[:]', $timediff);
Now the list function here would give me something like:
000300
I split this into 00 03 00
My worry is that when I compare a value to 03, PHP will not recognise it.
For example: if ($mins >= 3) {header('location:login.php');}
Is there a better way of comparing the time retrieved from a database?
If you were using MySQL >= 5.0 you could use TIMESTAMPDIFF:
SELECT
SessionID,
TIMESTAMPDIFF(MINUTE, LastSessionUpdate, NOW()) AS diff
FROM Sessions ...