soupy1985 Posted September 8, 2008 Share Posted September 8, 2008 Hello Guys I have a login system and I am trying to make a page that will display inactive users from the past 30 days. But i cant get it working. This is what I have so far... // $timestamp = 1220895924 gets this from the DB. <? if (time() - $timestamp > (30*24*60*60)) { echo "inactive"; } ?> Link to comment https://forums.phpfreaks.com/topic/123308-solved-unix-time-stamp/ Share on other sites More sharing options...
BlueSkyIS Posted September 8, 2008 Share Posted September 8, 2008 what's not working? Link to comment https://forums.phpfreaks.com/topic/123308-solved-unix-time-stamp/#findComment-636832 Share on other sites More sharing options...
soupy1985 Posted September 8, 2008 Author Share Posted September 8, 2008 Nothing is happening. Link to comment https://forums.phpfreaks.com/topic/123308-solved-unix-time-stamp/#findComment-636833 Share on other sites More sharing options...
soupy1985 Posted September 8, 2008 Author Share Posted September 8, 2008 Do i have to convert the time stamp to a time and date first? Link to comment https://forums.phpfreaks.com/topic/123308-solved-unix-time-stamp/#findComment-636835 Share on other sites More sharing options...
BlueSkyIS Posted September 8, 2008 Share Posted September 8, 2008 is $timestamp what you expect it to be? i'd check: <?php if (time() - $timestamp > (30*24*60*60)) { echo "inactive: $timestamp"; } else { echo "active: $timestamp"; } ?> Link to comment https://forums.phpfreaks.com/topic/123308-solved-unix-time-stamp/#findComment-636836 Share on other sites More sharing options...
soupy1985 Posted September 8, 2008 Author Share Posted September 8, 2008 Right i got that working, lol Now i am trying to get who has been online in the last 30 min, any ideas? $sql = "SELECT * FROM members"; $result = mysql_query($sql, $conn) or die(mysql_error()); while ($newArray = mysql_fetch_array($result)) { $login = $newArray['login']; $timestamp = $newArray['timestamp']; if (time() - $timestamp < (00*00*30*60)) { echo "$login<br>"; } } Link to comment https://forums.phpfreaks.com/topic/123308-solved-unix-time-stamp/#findComment-636848 Share on other sites More sharing options...
BlueSkyIS Posted September 8, 2008 Share Posted September 8, 2008 Right i got that working, lol Now i am trying to get who has been online in the last 30 min, any ideas? $sql = "SELECT * FROM members"; $result = mysql_query($sql, $conn) or die(mysql_error()); while ($newArray = mysql_fetch_array($result)) { $login = $newArray['login']; $timestamp = $newArray['timestamp']; if (time() - $timestamp < (00*00*30*60)) { echo "$login<br>"; } } yes. multiplying anything by 0 equals 0. Link to comment https://forums.phpfreaks.com/topic/123308-solved-unix-time-stamp/#findComment-636860 Share on other sites More sharing options...
soupy1985 Posted September 8, 2008 Author Share Posted September 8, 2008 Can someone break 30*24*60*60, what will it have to be to get 30 min? Link to comment https://forums.phpfreaks.com/topic/123308-solved-unix-time-stamp/#findComment-636863 Share on other sites More sharing options...
BlueSkyIS Posted September 8, 2008 Share Posted September 8, 2008 number of seconds per minute * number of minutes. Link to comment https://forums.phpfreaks.com/topic/123308-solved-unix-time-stamp/#findComment-636864 Share on other sites More sharing options...
soupy1985 Posted September 8, 2008 Author Share Posted September 8, 2008 What does it have to be to get it to get all the timestamps from the last 30 min? if (time() - $timestamp < (00*00*30*60)) { ???? Link to comment https://forums.phpfreaks.com/topic/123308-solved-unix-time-stamp/#findComment-636865 Share on other sites More sharing options...
revraz Posted September 8, 2008 Share Posted September 8, 2008 You dont HAVE to do your compare like that, it's not a requirement that you use 4 sets of numbers, it just makes it easier to get to seconds. So just use 1800. Link to comment https://forums.phpfreaks.com/topic/123308-solved-unix-time-stamp/#findComment-636876 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.