# Event future dates only?

**URL:** <https://forum.getkirby.com/t/event-future-dates-only/31596>\
**Category:** Questions\
**Created:** [May 13, 2024, 4:29pm UTC](https://forum.getkirby.com/t/event-future-dates-only/31596 "2024-05-13T16:29:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![urbanedge](https://avatars.discourse-cdn.com/v4/letter/u/cab0a1/32.png) [@urbanedge](https://forum.getkirby.com/u/urbanedge)\
**Post date:** [May 13, 2024, 4:29pm UTC](https://forum.getkirby.com/t/event-future-dates-only/31596/1 "2024-05-13T16:29:20Z")

</div>

I’ve followed the tutorial to create an events section on the website:

> **[Events](https://getkirby.com/docs/reference/panel/samples/events)**
>
> Announce your next get-togethers

I’ve added a sort by to place the events in order:  
$events = $EventsPage-\>children()-\>listed()-\>sortBy(‘from’, ‘asc’);

I would like previous events to today to not show, I’m not sure how to filter this as there are so may posts about it, but none are clear enough based on the tutorial example.

---

<div class="post-metadata">

**Author:** ![GB\_DESIGN](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/gb_design/32/14956_2.png) [@GB\_DESIGN](https://forum.getkirby.com/u/GB_DESIGN)\
**Post date:** [May 13, 2024, 6:20pm UTC](https://forum.getkirby.com/t/event-future-dates-only/31596/2 "2024-05-13T18:20:22Z")

</div>

I have tried out the cookbook in a fresh starter kit.  
With the following change, only the future events are output:

```auto
/site/templates/events.php

```

```auto
// before
$events = $page->children()->listed();
if ($events->count() > 0): ?>

```

```auto
// after
$events = $page->children()->filter(function ($child) {
return $child->to()->toDate() > time();
});
if ($events->count() > 0): ?>

```

And if you want the current event to be displayed first, add `flip()`.

```auto
$events = $page->children()->filter(function ($child) {
return $child->to()->toDate() > time();
})->flip();
if ($events->count() > 0): ?>

```

 ![event-list](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/3/3b98f828d816c1d289dd5dfe5f21127f44d9a4b2.png)

---

<div class="post-metadata">

**Author:** ![bnomei](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/bnomei/32/775_2.png) [@bnomei](https://forum.getkirby.com/u/bnomei)\
**Post date:** [May 14, 2024, 6:47am UTC](https://forum.getkirby.com/t/event-future-dates-only/31596/3 "2024-05-14T06:47:07Z")

</div>

this plugin might also help in filtering dates.

> **[Date Methods](https://plugins.getkirby.com/hananils/date-methods)**
>
> Date Methods is a plugin that allows for advanced date and time parsing and formatting using PHP's core date objects. It offers methods for fields to handle single dates, methods for pages to handle multiple dates (ranges) and also provides helper...

---

<div class="post-metadata">

**Author:** ![urbanedge](https://avatars.discourse-cdn.com/v4/letter/u/cab0a1/32.png) [@urbanedge](https://forum.getkirby.com/u/urbanedge)\
**Post date:** [May 15, 2024, 7:45am UTC](https://forum.getkirby.com/t/event-future-dates-only/31596/4 "2024-05-15T07:45:36Z")

</div>

Thank you so much, that worked great!
