Jump to content


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


Timestamp Query!!

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.

Share this post

Link to post
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)

Share this post

Link to post
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.

$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

Or you could just save the timestamp value so you don't need to convert backwards and forwards.

Share this post

Link to post
Share on other sites


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.