seany123 Posted March 31, 2009 Share Posted March 31, 2009 okay i have this code.... <?php if ($profile['last_active'] >= Time()-1200) { echo "NOW!"; } else { echo date("F j, Y, g:i a", $profile['last_active']); } ?> instead of the echo date("F j, Y, g:i a", $profile['last_active']); i want it to instead to show minutes since last active.. both last->active and time() are big long numbers and i just cant figure out how to make them show the real values. for example i want it to say like: last active: 3 days, 42mins and 30 seconds... all help would be great! Seany Quote Link to comment https://forums.phpfreaks.com/topic/151959-last-active-time-help/ Share on other sites More sharing options...
Brian W Posted March 31, 2009 Share Posted March 31, 2009 http://blog.evandavey.com/2008/04/php-date-in-human-readable-form-facebook-style.html Quote Link to comment https://forums.phpfreaks.com/topic/151959-last-active-time-help/#findComment-797977 Share on other sites More sharing options...
seany123 Posted March 31, 2009 Author Share Posted March 31, 2009 thanks for the link... im afraid its just made things more confusing. Quote Link to comment https://forums.phpfreaks.com/topic/151959-last-active-time-help/#findComment-798017 Share on other sites More sharing options...
seany123 Posted March 31, 2009 Author Share Posted March 31, 2009 any other help would be great. Quote Link to comment https://forums.phpfreaks.com/topic/151959-last-active-time-help/#findComment-798041 Share on other sites More sharing options...
premiso Posted April 1, 2009 Share Posted April 1, 2009 Funny, just posted this else where. But it works for here too: Found this little snippet function search($session_time) { //$session_time ="1151348975"; echo"You Entered: $session_time <BR>"; echo"The Current Time is = ".time()."<BR>"; $time_difference = time() - $session_time ; echo"time_difference = ".$time_difference."<HR>"; $seconds = $time_difference ; $minutes = round($time_difference / 60 ); $hours = round($time_difference / 3600 ); $days = round($time_difference / 86400 ); $weeks = round($time_difference / 604800 ); $months = round($time_difference / 2419200 ); $years = round($time_difference / 29030400 ); echo"seconds: $seconds<br>"; echo"minutes: $minutes<br>"; echo"hours: $hours<br>"; echo"days: $days<br>"; echo"weeks: $weeks<br>"; echo"months: $months<br>"; echo"years: $years<br>"; } From: http://www.wallpaperama.com/forums/learn-php-time-function-to-display-time-hours-days-weeks-months-years-t1033.html Hopefully that helps ya out. Quote Link to comment https://forums.phpfreaks.com/topic/151959-last-active-time-help/#findComment-798773 Share on other sites More sharing options...
seany123 Posted April 8, 2009 Author Share Posted April 8, 2009 how does that work? Quote Link to comment https://forums.phpfreaks.com/topic/151959-last-active-time-help/#findComment-804896 Share on other sites More sharing options...
premiso Posted April 9, 2009 Share Posted April 9, 2009 echo timeSince($profile['last_active']); function timeSince($urtime) { $seconds = (((time() - $urtime) / 1) % 60); $minutes = (intval((time() - $urtime) / 60) % 60); $hours = intval((time() - $urtime) / 3600); $days = intval((time() - $urtime) / 86400); $weeks = intval((time() - $urtime) / 604800); $months = intval((time() - $urtime) / 2419200); $years = intval((time() - $urtime) / 29030400); $result = array(); $result['years'] = ($years) ? sprintf('%u year%s,', number_format($years), ($years > 1) ? 's' : '') : FALSE; $result['months'] = ($months) ? sprintf('%u month%s,', number_format($months), ($months > 1) ? 's' : '') : FALSE; $result['weeks'] = ($weeks) ? sprintf('%u week%s,', number_format($weeks), ($weeks > 1) ? 's' : '') : FALSE; $result['days'] = ($days) ? sprintf('%u day%s,', number_format($days), ($days > 1) ? 's' : '') : FALSE; $result['hours'] = ($hours) ? sprintf('%u hour%s,', number_format($hours), ($hours > 1) ? 's' : '') : FALSE; $result[minutes'] = ($minutes) ? sprintf('%u minute%s', $minutes, ($minutes > 1) ? 's' : FALSE) : FALSE; $result['seconds'] = ($seconds) ? sprintf('%s %u second%s',($minutes) ? 'and' : '', $seconds, ($seconds > 1) ? 's' : FALSE) : FALSE; return (count($result) == 0) ? 'Never' : implode(' ', $result).' ago'; } Quote Link to comment https://forums.phpfreaks.com/topic/151959-last-active-time-help/#findComment-805160 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.