Show "New" banner if publish date is less than a week ago

Hi,

I have a postedDate field on a page. The content looks like this:

2025-05-15T12:55:08.821Z

When looping through the pages as part of a listing, I want to display a little “New” icon if this date is less than a week ago. What would be the best way of doing this in Kirby? This is my current code, with a placeholder to show what I mean:

<?php foreach ($vacancies as $job): ?>
  <div>
    <?php if($job->postedDate() /* is less than a week ago */): ?>
      <p>New!</p>
    <?php endif ?>
    <h2><?= $job->title() ?></h2>
    <?php if($job->location()->isNotEmpty()): ?>
      <p><?= $job->location() ?></p>
    <?php endif ?>
    <?php if($job->text()->isNotEmpty()): ?>
      <p><?= $job->text() ?></p>
    <?php endif ?>
    <a href="<?= $job->url() ?>">View Details</a>
  </div>
<?php endforeach; ?>

Thanks for any help anyone can offer

<?php if($job->postedDate() > (time() - 7 * 24 * 3600)): ?>
1 Like

Awesome, thank you