Output UNIX timestamp when creating a page

Hello, I would like to display on my website a box of the unread articles within a certain period of time.
So far I have done this with “modified”:

  <?php
 date_default_timezone_set('Europe/Berlin');
 $timestamp = time();
 $lastTime = $_COOKIE["lastTime"];
 $unread = page('news')->children()->visible()->filterBy('modified', '>', $lastTime);
 echo $lastTime;
 echo "<br>";
 echo $unread;

 setcookie("lastTime", $timestamp, time() + (86400 * 30), "/");
?>

But I do not want to see a field appear every time an article is changed.
Is there a better way?
Thanks in advance!

Hm, I’d love to help but I don’t understand your use case, I’m afraid. How are unread articles defined?

A page is modified when it is changed in the Panel or it’s timestamp is changed.

If you want the date the page was created, then you could give your page a (hidden) date time field that defaults to now, for example.

Sorry I mean of course only the new articles since the last visit.
And not the unread, that would be something completely different … :joy:

I only want to display the articles that have been published in the meantime of the last visit.

I am sorry, my mistake…

I have already edited my post above. If those page are articles, they probably have a date field anyway, don’t they?

A panel.page.create hook that saves a creation date to file would be an alternative.

I had thought of that before, but I would like to publish the date and time as one timestamp because several articles are published per day. Is that possible?

Sorry I’m new to Kirby …

The datetime field should save date and time in one field …

Okay, thanks a lot for the quick and good help!

You are welcome! Always here to try and make you happy :wink: