<p>You would need to pass in "now" unmodified and "date_modify" the value in the database to midnight to do the comparison you're after. Unfortunately that's not possible with an element criteria model.</p>

<p>As already mentioned in the comments, set an expiry date. I have written a plugin to set it automatically:</p>

<p><a href="https://github.com/carlcs/craft-autoexpire" rel="nofollow">https://github.com/carlcs/craft-autoexpire</a></p>

CC BY-SA 3.0
2015-12-10T00:17:01.530Z
2015-12-10T00:17:01.530Z
carlcs
<p>Have you tried?:</p>

<pre><code> {% set upcoming = craft.entries.section('gigEntry').status('pending', 'live').gigDate('&gt;= ' ~midnight) %}
</code></pre>

CC BY-SA 3.0
2015-12-09T15:41:03.117Z
2015-12-09T15:41:03.117Z
erwinheiser
<p>I have a list of events which should list each event until midnight of said day.</p>

<p>So If a gig happens at 17:00 it should still be visible until midnight of the same day.</p>

<p>I came relatively close (I guess) but it's not working:</p>

<pre><code>{% set nocturne = now|date_modify('today 00:00') %}
{% set midnight = nocturne|date('Y-m-d H:i') %}
</code></pre>

<p>This should set <code>{{ midnight }}</code> to midnight of the current day.</p>

<p>Then I translate the custom date field of each gig into the same format as <code>{{ mdinight }}</code></p>

<pre><code>{% set getFirstGig = craft.entries.section('gigEntry').first() %}
{% set gigDate = getFirstGig.konzertDatum|date('Y-m-d H:i') %}
</code></pre>

<p>Then I want to call the whole thing:</p>

<pre><code> {% set upcoming = craft.entries.section('gigEntry').gigDate('&gt;= ' ~midnight) %}
 {% for entry in upcoming %}
   &lt;h2&gt;{{ entry.title }}&lt;/h2&gt;
 {% endfor %}
</code></pre>

<p>The code actualy works but my test entry with the time 17:00 is not displayed here. What am I missing? And is there a neater way of writing things?</p>

CC BY-SA 3.0
2015-12-04T12:16:25.930Z
Could you not just set the expiry date on the event entry?
Andy
CC BY-SA 3.0
2015-12-07T06:53:36.430Z
So my client needs to put always two dates per entry? That's counter intuitive.
KSPR
CC BY-SA 3.0
2015-12-07T11:15:15.340Z
Fair enough.........
Andy
<datetime><events>
Show events until Midnight
# Show events until Midnight

(Asked by: username_0 on 2015-12-04)

I have a list of events which should list each event until midnight of said day.
So If a gig happens at 17:00 it should still be visible until midnight of the same day.
I came relatively close (I guess) but it's not working:
{% set nocturne = now|date_modify('today 00:00') %}
{% set midnight = nocturne|date('Y-m-d H:i') %}

This should set {{ midnight }} to midnight of the current day.
Then I translate the custom date field of each gig into the same format as {{ mdinight }}
{% set getFirstGig = craft.entries.section('gigEntry').first() %}
{% set gigDate = getFirstGig.konzertDatum|date('Y-m-d H:i') %}

Then I want to call the whole thing:
 {% set upcoming = craft.entries.section('gigEntry').gigDate('>= ' ~midnight) %}
 {% for entry in upcoming %}
   {{ entry.title }}
 {% endfor %}

The code actualy works but my test entry with the time 17:00 is not displayed here. What am I missing? And is there a neater way of writing things?

**Tags:** datetime, events
> **Comments:**
> **username_1**: Could you not just set the expiry date on the event entry?  
> **username_0**: So my client needs to put always two dates per entry? That's counter intuitive.  
> **username_1**: Fair enough.........  

---

## 2 answers

### Answer by username_2 on 2015-12-10. Score: 2 | Accepted answer

You would need to pass in "now" unmodified and "date\_modify" the value in the database to midnight to do the comparison you're after. Unfortunately that's not possible with an element criteria model.

As already mentioned in the comments, set an expiry date. I have written a plugin to set it automatically:

<https://github.com/carlcs/craft-autoexpire>


---

### Answer by username_3 on 2015-12-09. Score: 3

Have you tried?:
 {% set upcoming = craft.entries.section('gigEntry').status('pending', 'live').gigDate('>= ' ~midnight) %}


---

