Hide div after certain time


I’m working on some kind of blog/archive and I was wondering if there is a way to display a »new« and »edited« div which disappears after a certain time.

I guess there is one but I have no clue how to do so :blush:

I’m eager to hear your solutions
kind regards in advance


I don’t know how familiar you are with PHP. But displaying a “new” badge of some sorts is pretty straight forward.
You will need a date field on the article that gets updated when saving/editing and a defined time span when articles are still considered “new”.
In the articles template you will just need to check wether today is after the date field plus the time span.

If you need help with the actual code, just reply.


Hi Thomas,

I’m learning php with kirby, so there is a very bad base knowledge of it.

That’s what I’ve found in a stack overflow, which should work:

<?php if ( time() - $data->time < 259200 ):?>
<div class="listing-time"><?php echo timespan($data->time); ?> since</div>
<?php endif;?>

Actually it seems quite logical but it doesn’t work. The first line reads:
if actual time – article time is smaller then 3 days: do something

instead of $date->time I’ve put $article->date(‘c’, ‘date’)->time to fetch the article time.
Is this correct? What does <?php echo timespan($data->time); ?> mean?

Sorry for my lacking skills in php. :blush:

Unfortunately you do not link to your source, so it’s impossible to tell where the timespan stems from.

Here is a possible solution, guess, there are other ways of solving this:

$articles = $page->children()->visible()->filter(function($article) {
    $time = new DateTime('now'); 
    $published = new Datetime($article->date('Y-m-d')); 
    $interval = (int)$published->diff($time)->format('%a');
    if($interval < 3) {
      return $article;
foreach($articles as $article) {
	echo $article->title();


The above code uses a custom filter with a callback http://getkirby.com/docs/cheatsheet/pages/filter, and the php DateTime class http://php.net/manual/de/book.datetime.php