Commit
This commit is contained in:
parent
195d72b0f3
commit
983af52653
@ -1,3 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
function get_time_ago_human($time) {
|
||||||
|
$time = time() - $time;
|
||||||
|
$time = ($time<1)? 1 : $time;
|
||||||
|
$tokens = array (
|
||||||
|
31536000 => 'year',
|
||||||
|
2592000 => 'month',
|
||||||
|
604800 => 'week',
|
||||||
|
86400 => 'day',
|
||||||
|
3600 => 'hour',
|
||||||
|
60 => 'minute',
|
||||||
|
1 => 'second'
|
||||||
|
);
|
||||||
|
foreach ($tokens as $unit => $text) {
|
||||||
|
if ($time < $unit) continue;
|
||||||
|
$numberOfUnits = floor($time / $unit);
|
||||||
|
return $numberOfUnits.' '.$text.(($numberOfUnits>1)?'s':'');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
@ -27,7 +47,7 @@
|
|||||||
|
|
||||||
<?php foreach($messages as $message): ?>
|
<?php foreach($messages as $message): ?>
|
||||||
<div>
|
<div>
|
||||||
<small><span style="color: yellow"><?=htmlspecialchars($message['nick'])?></span> <?=gmdate("D M j G:i:s Y", $message['date']);?></small>
|
<small><span style="color: yellow"><?=htmlspecialchars($message['nick'])?></span> <?=get_time_ago_human($message['date']) . ' ago'//gmdate("D M j G:i:s Y", $message['date']);?></small>
|
||||||
<p><?=htmlspecialchars($message['text'])?></p>
|
<p><?=htmlspecialchars($message['text'])?></p>
|
||||||
</div>
|
</div>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
Loading…
Reference in New Issue
Block a user