Gayner Posted November 16, 2009 Share Posted November 16, 2009 function time_elapsed_string($ptime) { $etime = time() - $ptime; if ($etime < 1) { return '0 seconds'; } $a = array( 12 * 30 * 24 * 60 * 60 => 'year', 30 * 24 * 60 * 60 => 'month', 24 * 60 * 60 => 'day', 60 * 60 => 'hour', 60 => 'minute', 1 => 'second' ); foreach ($a as $secs => $str) { $d = $etime / $secs; if ($d >= 1) { $r = round($d); return $r . ' ' . $str . ($r > 1 ? 's ago' : ''); } } } Everything works fine.. I get 25, seconds ago bla bla. But when It get's into minutes.. it only does 4 Minutes ago. I want it to be, 4Minutes 28Seconds ago. Or whatever. Sorry but this is the farthest i gotten in php code now i need ur help thanks. Link to comment https://forums.phpfreaks.com/topic/181702-help-my-date-function-i-almost-got-it/ Share on other sites More sharing options...
chadayers Posted November 16, 2009 Share Posted November 16, 2009 I can fix this, just need the complete code. Link to comment https://forums.phpfreaks.com/topic/181702-help-my-date-function-i-almost-got-it/#findComment-958331 Share on other sites More sharing options...
Gayner Posted November 16, 2009 Author Share Posted November 16, 2009 I can fix this, just need the complete code. This is the complete code, lol it works fine right now i just use the function around a time format example: ".time_elapsed_string($rowr['date'])." anyone still help me? Link to comment https://forums.phpfreaks.com/topic/181702-help-my-date-function-i-almost-got-it/#findComment-958332 Share on other sites More sharing options...
Gayner Posted November 16, 2009 Author Share Posted November 16, 2009 I went to sleep and waking up and failing to see a new post... lol somone here gota help me thanks! Link to comment https://forums.phpfreaks.com/topic/181702-help-my-date-function-i-almost-got-it/#findComment-958459 Share on other sites More sharing options...
Gayner Posted November 17, 2009 Author Share Posted November 17, 2009 Bump Link to comment https://forums.phpfreaks.com/topic/181702-help-my-date-function-i-almost-got-it/#findComment-958824 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.