Jump to content

Timestamp Query!!


xyn

Recommended Posts

Hey guys,
Just have a short, quick querstion. I have a admin control unit
and I wanted to add a 5 minute inactivity, everytime the page
is refreshed (uses another page within the acp) The time stamp
is updated

Yet if the admin leaves their accoutn for over 5 minutes when
they refresh the page it checks the Current time with the timestamp
and it tells them they're not logged in?

My clock formatt is... H:i:s, (00:00:00) could someone give me a small
pointer on how to fix this.
Thanks!
Link to comment
https://forums.phpfreaks.com/topic/21876-timestamp-query/
Share on other sites

Sorry If i explained badly, The problem is, I wanted to create
a 5 minute inactivity, which means when my sessions checking
page reloads (as it does on every page inside the acp) then the
timestamp changes. So if 5 minutes pass and they don't change
their page I want the time stamp to reconise 5 minutes inactivity
and tell them heir not active, and sign them out :/

I can do everything else, just not sure about the time stamp.
My clock / time format is(H:i:s) which is 00:00:00
(0-24 hr; 0-59mins; 0-59 secs)
Link to comment
https://forums.phpfreaks.com/topic/21876-timestamp-query/#findComment-97997
Share on other sites

If you are using H:i:s the you need to convert to timestamp with strtotime() before you do any maths.

[code]<?php
$saved_time = $_SESSION['saved_time'];

$time_now = time();

$time_since_last_used = ($time_now - strtotime($saved_time));  // convert to tstamp

if ($time_since_last_used > 300) {
    echo "Over 5 mins<br>";
    // clear session data
    // transfer to login
}
else {
    $_SESSION['saved_time'] = date('H:i:s', $time_now); // convert to H:i:s
}
?>[/code]

Or you could just save the timestamp value so you don't need to convert backwards and forwards.
Link to comment
https://forums.phpfreaks.com/topic/21876-timestamp-query/#findComment-98021
Share on other sites

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.