function time_elapsed_string($ptime)
{
$etime = time() - $ptime;
if ($etime < 1)
{
return '0 seconds';
}
$a = array( 365 * 24 * 60 * 60 => 'year',
30 * 24 * 60 * 60 => 'month',
24 * 60 * 60 => 'day',
60 * 60 => 'hour',
60 => 'minute',
1 => 'second'
);
$a_plural = array( 'year' => 'years',
'month' => 'months',
'day' => 'days',
'hour' => 'hours',
'minute' => 'minutes',
'second' => 'seconds'
);
foreach ($a as $secs => $str)
{
$d = $etime / $secs;
if ($d >= 1)
{
$r = round($d);
return $r . ' ' . ($r > 1 ? $a_plural[$str] : $str) . ' ago';
}
}
}
Well, in my cms I'm just passing last_online from the database through this function
Didn't write this function myself - so kudos to whoever out on the internet did.PHP:function time_elapsed_string($ptime) { $etime = time() - $ptime; if ($etime < 1) { return '0 seconds'; } $a = array( 365 * 24 * 60 * 60 => 'year', 30 * 24 * 60 * 60 => 'month', 24 * 60 * 60 => 'day', 60 * 60 => 'hour', 60 => 'minute', 1 => 'second' ); $a_plural = array( 'year' => 'years', 'month' => 'months', 'day' => 'days', 'hour' => 'hours', 'minute' => 'minutes', 'second' => 'seconds' ); foreach ($a as $secs => $str) { $d = $etime / $secs; if ($d >= 1) { $r = round($d); return $r . ' ' . ($r > 1 ? $a_plural[$str] : $str) . ' ago'; } } }
In the database lol.Thanks but where do I put this? I tried to put it on my staff page but I get a white screen.
function relative_time($time)
{
$SECOND = 1;
$MINUTE = 60 * $SECOND;
$HOUR = 60 * $MINUTE;
$DAY = 24 * $HOUR;
$MONTH = 30 * $DAY;
$before = time() - $time;
if ($before < 0) {
return "not yet";
}
if ($before < 1 * $MINUTE) {
//return ($before <= 1) ? "just now" : $before . " seconds ago";
return "just now";
}
if ($before < 2 * $MINUTE) {
return "1 minute ago";
}
if ($before < 45 * $MINUTE) {
return floor($before / 60) . " minutes ago";
}
if ($before < 90 * $MINUTE) {
return "an hour ago";
}
if ($before < 24 * $HOUR) {
return (floor($before / 60 / 60) == 1 ? 'about an hour' : floor($before / 60 / 60) . ' hours') . " ago";
}
if ($before < 48 * $HOUR) {
return "yesterday";
}
if ($before < 30 * $DAY) {
return floor($before / 60 / 60 / 24) . " days ago";
}
if ($before < 12 * $MONTH) {
$months = floor($before / 60 / 60 / 24 / 30);
return $months <= 1 ? "one month ago" : $months . " months ago";
} else {
$years = floor($before / 60 / 60 / 24 / 30 / 12);
return $years <= 1 ? "one year ago" : $years . " years ago";
}
return "$time";
}
"lol"? Like it was obvious. Hah.. you do know that you're wrong, right?In the database lol.
I'm not using rev, so I don't know where the most reasonable place to put it is, but chuck it into one of the classes and call it on the staff page where you would normally get staff members by doing time_elapsed_string(this-is-where-you-get-last-online).Thanks but where do I put this? I tried to put it on my staff page but I get a white screen.
You do know it was a joke?"lol"? Like it was obvious. Hah.. you do know that you're wrong, right?
I'm not using rev, so I don't know where the most reasonable place to put it is, but chuck it into one of the classes and call it on the staff page where you would normally get staff members by doing time_elapsed_string(this-is-where-you-get-last-online).
Easily, he doesn't know what is the thing you sent him?It's called Help and Support for a reason, fool.You do know it was a joke?
Hah, how could you even run that ?
In my view, it makes no sense to intentionally set a person in need of help on the wrong path. Don't be such an ass.You do know it was a joke?
Hah, how could you even run that ?
public static function getStaff($rank)
{
if(DB::getInstance()->query("SELECT * FROM users WHERE rank = $rank")->count())
{
$oddEven = "odd";
$getStaff = DB::getInstance()->query("SELECT * FROM users WHERE rank = $rank ORDER BY id ASC");
foreach($getStaff->results() as $staff) {
if($oddEven == "#F5F5F5")
{
$oddEven = "#FFFFFF";
}
else
{
$oddEven = "#F5F5F5";
}
if($staff->online == 1)
{
$onlineStatus = "<img src='{site_url}/library/templates/tmp/images/staff/online.gif'>";
}
else
{
$onlineStatus = "<img src='{site_url}/library/templates/tmp/images/staff/offline.gif'>";
}
echo '<table width="100%" style="padding: 2px; background-color: ' . $oddEven . ';"><tbody><tr>
<td valign="middle" width="25">
<div style="width: 54px; height: 54px; margin-top:-10px; float: left; background: url(https://www.habbo.com.tr/habbo-imaging/avatarimage?figure=' . $staff->look . '&gesture=sml&size=m&headonly=1);"></div>
</td>
<td valign="top">
<b style="font-size: 110%;">' . $staff->username . '</b> <font size="1"></a>' . $staff->position . '</font>
<br />
Motto: <i>' . $staff->motto . '</i><br>
Last seen: ' . Light::time_elapsed_string($staff->last_online) . '<br>
</td>
<td valign="top" style="float: right;">
' . $onlineStatus . '
</td>
</tr></tbody></table>';
}
}
else {
echo '<div class="habblet box-content" style="margin-top:-5px;"><i>There are no staff members in this category.</i></div>';
}
}
return $r . ' ' . ($r > 1 ? $a_plural[$str] : $str) . ' ago';
return $r . ' ' . ($r > 1 ? ($str.'s') : $str) . ' ago';