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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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