Hello!
I try to use sorting for the events - right now I sort it by date.
I would want it to sort by the time the event starts as well
this is my code at the moment:
<?php
$today = date('Y-m-d');
$events = page()->children()->template('event')
->filter(fn ($p) => $p->date()->toDate('Y-m-d') === $today);
$sortedEvents = $events->sortBy(function ($page) {
return $page->date()->toDate();
});
foreach($sortedEvents->limit(2) as $event): ?>
<?php snippet('event', ['event'=>$event])?>
<?php endforeach ?>
any idea how can I achieve that?
this is my yml:
sections:
times:
type: fields
fields:
date:
label: date
type: date
display: DD MMMM YYYY
starts:
label: time starts
type: time
display: HH:mm
ends:
label: time ends
type: time
display: HH:mm
I would appreciate any help - thanks !