{timeago}
How long ago a moment was, in words, inside a time element that keeps the exact moment as its datetime and title.
Syntax
{timeago $moment}
{timeago $moment, now='2026-10-08 12:00', format='j M Y'}
Parameters
-
moment - A Unix timestamp, a date in text or a date object. An empty moment writes nothing.
Options
-
now - Count from this moment instead of now.
-
format -
The PHP date format of the full moment in the
title, defaultl j F Y, H:i.
Description
{timeago $created} writes how long ago the moment was - just now, 5 minutes ago, yesterday, 3 weeks ago, and for a moment still to come, in 2 days - inside a <time class="pad-timeago">. The element's datetime is the moment in ISO 8601, for machines, and its title the moment in full, which a browser shows on hover. The words are those of the ago pipe, with the semantic element around them.
Now is padNow (), so padNowFreeze () in PHP holds a page still for a test. now= counts from a given moment instead - which is how the examples here stay the same on every request. format= is the PHP date format of the title.
An empty moment writes nothing, so a row without a date leaves no empty element behind. A moment, or a now=, that cannot be read as a date is a strict error. For the time left until a moment, use {countdown}.
Examples
A comment thread
Each comment says how long before the fixed now it was posted; hover a time for the full moment.
<ul>
{comments}
<li><strong>{$name}</strong> - {timeago $posted, now='2026-10-08 12:00'}: {$text}</li>
{/comments}
</ul>
<?php
$comments = [
[ 'name' => 'Maya', 'posted' => '2026-06-02 09:00', 'text' => 'Can the report be a spreadsheet?' ],
[ 'name' => 'Jonas', 'posted' => '2026-09-17 15:30', 'text' => 'The CSV answer of the page does it.' ],
[ 'name' => 'Priya', 'posted' => '2026-10-07 10:00', 'text' => 'One line in the page and it works.' ],
[ 'name' => 'Tomás', 'posted' => '2026-10-08 09:45', 'text' => 'Can the columns be chosen?' ],
[ 'name' => 'Ken', 'posted' => '2026-10-08 11:55', 'text' => 'Yes - list them in the page.' ] ];
?>
- Maya - : Can the report be a spreadsheet?
- Jonas - : The CSV answer of the page does it.
- Priya - : One line in the page and it works.
- Tomás - : Can the columns be chosen?
- Ken - : Yes - list them in the page.
Past and future, another title
A moment still to come reads as in ...; format= changes the full date in the title.
<p>Released {timeago '2026-09-01', now='2026-10-08 12:00', format='j M Y'}.</p>
<p>Next release {timeago '2026-10-22', now='2026-10-08 12:00', format='j M Y'}.</p>
<p>Not dated: [{timeago ''}]</p>
Released .
Next release .
Not dated: []
See also
- {countdown} The time left until a moment, in words inside a time element - ticking every second in the browser when asked.
- {calendar} Writes a month as a calendar table with its events, or hands over its weeks and days as rows for markup of your own.
- {echo} Evaluates an expression and prints the result - the general output tag, and the one to put in front of a pipe.