<p>For me it worked after I changed the date format into <code>{% set today = now|date('Y-m-d') %}</code>, so I think this should work:</p>

<pre><code>{% set startAfterTime = '17.00'|date('U') %}
{% set today = now|date('Y-m-d') %}

{% set events = craft.entries()
    .section('events')
    .status(['live', 'pending'])
    .postDate('&gt;=' ~ today )
    .eventStartTime('&gt;=' ~ startAfterTime)
    .all() %}
</code></pre>

CC BY-SA 4.0
2019-11-22T08:13:07.737Z
2019-11-23T00:27:04.293Z
2019-11-23T00:27:04.293Z
Marcel
<p>That will give you all entries, from today (so not past entries) starting after 5PM:</p>

<pre class="lang-twig prettyprint-override"><code>{% set startAfterTime = '17.00'|date('U') %}
{% set today = now|atom|date %}

{% set events = craft.entries()
    .section('events')
    .status(['live', 'pending'])
    .postDate('&gt;=' ~ today )
    .eventStartTime('&gt;=' ~ startAfterTime)
    .all() %}
</code></pre>

CC BY-SA 4.0
2019-04-01T07:38:46.067Z
This is pretty much identical to the approach I tried first and unfortunately does not work, I just have all entries returned to me.
jaypratt
CC BY-SA 4.0
2019-04-01T12:03:54.217Z
@jaypratt that's really strange, I tested it here as well? Is it just a standard entry Section..?
Oli
CC BY-SA 4.0
2019-04-02T14:19:44.150Z
Yep - just a channel.
jaypratt
CC BY-SA 4.0
2019-03-29T19:35:34.187Z
2019-03-30T16:03:30.467Z
2019-03-30T16:03:30.467Z
Oli
<p>I am trying to get all entries from my events section in Craft 3 that occur after 17:00.</p>

<p>My current code is:
<code>{% set events = craft.entries.section('events').eventStartTime('&gt;= ' ~ '17:00'|time ).all() %}</code></p>

<p>The <code>&gt;=</code> is being ignored as far as I can tell. The query just returns all events.</p>

<p>The <code>eventStartTime</code> field is a Date/Time field that is set to just show the time (I know that behind the scenes Craft still treats this as a DateTime object but I was hoping that the <code>|time</code> filter would help with that.</p>

<p>When I have created similar queries on a DateTime field but looking at the date rather than time, they have worked as expected - maybe I am missing something when it comes to the time portion of the object? </p>

<p>Any help would be appreciated.</p>

CC BY-SA 4.0
2019-03-28T03:29:33.277Z
Is this Craft 2 or 3?
Brad Bell
CC BY-SA 4.0
2019-03-28T08:15:51.763Z
Ah sorry, Craft 3
jaypratt
<search><entry><datetime><query>
Get entries after a certain time
# Get entries after a certain time

(Asked by: username_0 on 2019-03-27)

I am trying to get all entries from my events section in Craft 3 that occur after 17:00.

My current code is:
`{% set events = craft.entries.section('events').eventStartTime('>= ' ~ '17:00'|time ).all() %}`

The `>=` is being ignored as far as I can tell. The query just returns all events.

The `eventStartTime` field is a Date/Time field that is set to just show the time (I know that behind the scenes Craft still treats this as a DateTime object but I was hoping that the `|time` filter would help with that.

When I have created similar queries on a DateTime field but looking at the date rather than time, they have worked as expected - maybe I am missing something when it comes to the time portion of the object?

Any help would be appreciated.

**Tags:** search, entry, datetime, query

> **Comments:**
> **username_1**: Is this Craft 2 or 3?  
> **username_0**: Ah sorry, Craft 3  

---

## 2 answers

### Answer by username_2 on 2019-11-22. Score: 3

For me it worked after I changed the date format into {% set today = now|date('Y-m-d') %}, so I think this should work:
{% set startAfterTime = '17.00'|date('U') %}
{% set today = now|date('Y-m-d') %}

{% set events = craft.entries()
    .section('events')
    .status(['live', 'pending'])
    .postDate('>=' ~ today )
    .eventStartTime('>=' ~ startAfterTime)
    .all() %}


---

### Answer by username_3 on 2019-03-29. Score: 2

That will give you all entries, from today (so not past entries) starting after 5PM:
{% set startAfterTime = '17.00'|date('U') %}
{% set today = now|atom|date %}

{% set events = craft.entries()
    .section('events')
    .status(['live', 'pending'])
    .postDate('>=' ~ today )
    .eventStartTime('>=' ~ startAfterTime)
    .all() %}

> **Comments:**
> **username_0**: This is pretty much identical to the approach I tried first and unfortunately does not work, I just have all entries returned to me.  
> **username_3**: @username_0 that's really strange, I tested it here as well? Is it just a standard entry Section..?  
> **username_0**: Yep - just a channel.  

---

