note 72349 deleted from function.time by nlopess

From: Date: Mon, 15 Jan 2007 18:41:12 +0000
Subject: note 72349 deleted from function.time by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-121747@lists.php.net to get a copy of this message
Note Submitter: jonas dot x5 at gmail dot com ---- I've edited the previouse code a bit, to make it more stable: $ts2 = $row['lastseen']; $ts=time()-$ts2; if ($ts<60 * 60) { echo "Member " . $row['name'] . " was last seen " . floor($ts/60) . " minutes ago at location " . $location; ?> <br> <? } elseif ($ts<60*60*24 AND $ts>60*60 ) { $test = 60*60; echo "Member " . $row['name'] . " was last seen " . floor($ts/$test) . " hours ago at location " . $location; ?> <br> <? } elseif ($ts<60*60*24*7 AND $ts>60*60*24) { $test = 60*60*24; echo "Member " . $row['name'] . " was last seen " . floor($ts/$test) . " days ago at location " . $location; ?> <br> <? } elseif ($ts<60*60*24*7*30.5 AND $ts>60*60*24*7) { $test = 60*60*24*7; echo "Member " . $row['name'] . " was last seen " . floor($ts/$test) . " weeks ago at location " . $location; ?> <br> <? } elseif ($ts<60*60*24*356 AND $ts>60*60*24*7*30.5) { $test = 60*60*24*7*30.5; echo "Member " . $row['name'] . " was last seen " . floor($ts/$test) . " months ago at location " . $location; ?> <br> <? } elseif ($ts<60*60*24*356*10 AND $ts>60*60*24*356) { $test = 60*60*24*356; echo "Member " . $row['name'] . " was last seen " . floor($ts/$test) . " years ago at location " . $location; ?> <br> <? } elseif ($ts<60*60*24*356*10*10 AND $ts>60*60*24*356*10) { $test = 60*60*24*356*10; echo "Member " . $row['name'] . " was last seen " . floor($ts/$test) . " decades ago at location " . $location; ?> <br> <? } All credits go to the last comment. // Jonas

« previous php.notes (#121747) next »