N-Bomb(Nerd) Posted May 4, 2009 Share Posted May 4, 2009 I'm giving consideration of adding a "Last Seen" feature to my website. I'm easily able to put the current time in the database when they're seen on any of my pages. However, what would be the proper date/time format when submitting that to the database? Also, what would be the proper way of calculating the days/time they've been inactive? I'm sure there's some fancy way to do this with a bit of math, but math is my worst. Link to comment https://forums.phpfreaks.com/topic/156750-last-seen/ Share on other sites More sharing options...
Ken2k7 Posted May 4, 2009 Share Posted May 4, 2009 TIMESTAMP would be my format. To calculate, you would just take the time it is now and subtract if from last seen time. =/ Link to comment https://forums.phpfreaks.com/topic/156750-last-seen/#findComment-825410 Share on other sites More sharing options...
mapleleaf Posted May 4, 2009 Share Posted May 4, 2009 put a time() in the database and then format it with date() when getting it out. PHP has great functions for working with date and time as does MySQL Link to comment https://forums.phpfreaks.com/topic/156750-last-seen/#findComment-825412 Share on other sites More sharing options...
N-Bomb(Nerd) Posted May 4, 2009 Author Share Posted May 4, 2009 Rofl, nvm this is harder than I thought.. the outputting format is a B***h. Link to comment https://forums.phpfreaks.com/topic/156750-last-seen/#findComment-825440 Share on other sites More sharing options...
fry2010 Posted May 4, 2009 Share Posted May 4, 2009 Calculate it within your mysql query: "SELECT DATEDIFF(NOW(), Last_logged_in) WHERE user = '$user'"; As long as you have last_logged_in as a mysql timestamp it shud work. Link to comment https://forums.phpfreaks.com/topic/156750-last-seen/#findComment-825443 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.