<div id="recentPastes">
<h2>Recent Pastings</h2>
<hr>
-<?php foreach ($recent as $r) {
- if (empty($r['title'])) {
- $r['title'] = _("[Untitled]");
- }
+<?php
+$now = new DateTime;
+foreach ($recent as $r) {
+ if (empty($r['title'])) {
+ $r['title'] = _("[Untitled]");
+ }
+ $then = new DateTime('@' . $r['timestamp']->timestamp());
+ $ago = $now->diff($then, true);
+ $days = $ago->format("%a");
+ if ($days > 0) {
+ $ago = $ago->format("%a days %H:%i ago");
+ } else {
+ $ago = $ago->format("%H:%i min ago");
+ }
?>
<div class="recentPaste">
<span class="pasteTitle"><a href="<?php echo $uuid . '/' . $r['uuid']; ?>"><?php echo $r['title']; ?></a></span><br>
<span class="pasteAuthor"><?php echo $r['owner']; ?></span> |
<span class="pasteSyntax"><?php echo $r['syntax']; ?></span> |
- <span class="pasteDate"><?php echo $r['timestamp']; ?></span>
+ <span class="pasteDate"><?php echo $ago; ?></span>
</div>
<hr>
<?php } ?>
/* Insert CSS definitions here. */
#recentPastes {
float: left;
- width: 20%;
+ width: 18%;
height: 100%;
border: 1px solid #c00;
padding: 2px;
overflow: hidden;
- margin: 50px 15px 10px 15px;
+ margin: 50px 10px 10px 10px;
}
.recentPaste {