in reply to Re: Using Timestamp to tell if someone is on the site
in thread Using Timestamp to tell if someone is on the site

Thank you, I figured it out although not as clean as you did. I inserted the date and time into separate database fields. I then split the lastvisittime and multiplied the hour by 60. I added that number to the minutes to get a time in minutes. I did the same for the current time, then subtracted the last visit from now. Thanks.
  • Comment on Re^2: Using Timestamp to tell if someone is on the site

Replies are listed 'Best First'.
Re^3: Using Timestamp to tell if someone is on the site
by huck (Prior) on Jan 05, 2017 at 05:31 UTC

    What if the last visit was at 23:59, and now is 00:01? The difference is negative which is less than 5 and says online and is right

    But what if the last visit was at 22:59, and now is 00:01? The difference is again negative which is less than 5 and says online, but wrong since it was more than 5 min ago

Re^3: Using Timestamp to tell if someone is on the site
by poj (Abbot) on Jan 05, 2017 at 18:22 UTC

    Consider calculating the time difference when you select the record. For example in MySQL

    SELECT TIMESTAMPDIFF(SECOND,lastvisit,NOW()) FROM table

    Change SECOND to MINUTE as required.

    poj