<p>Your <code>entry.expiration</code> is actually an object of type DateTime thus you'll have the full power of PHPs <a href="http://php.net/manual/en/datetime.diff.php" rel="nofollow noreferrer">DateDiff</a> functionality </p>

<pre><code>$interval = $datetime1-&gt;diff($datetime2);
</code></pre>

<p>In Twig this is something like </p>

<pre><code>{% set difference = now.diff(entry.expiration) %} 
{{ difference.format('%R%a days') }} 
</code></pre>

<p><code>now</code> should be the current date </p>

CC BY-SA 4.0
2018-06-02T12:38:44.817Z
2018-06-02T14:16:39.820Z
2018-06-02T14:16:39.820Z
Robin Schambach
<p>I'm trying to display how long til a certain post expires depending on a date/time field. </p>

<p><strong>Example</strong></p>

<blockquote>
  <p>Expires in 13 days.</p>
</blockquote>

<p>My field is currently displayed by doing <code>{{ entry.expiration }}</code></p>

<p>I just don't know how I would just display the days remaining until this date.</p>

<p>Thanks</p>

<templating><entries>
Displaying how long til post expires
# Displaying how long til post expires

(Asked by: username_0 on 2018-06-02)

I'm trying to display how long til a certain post expires depending on a date/time field.

**Example**

> Expires in 13 days.

My field is currently displayed by doing `{{ entry.expiration }}`

I just don't know how I would just display the days remaining until this date.

Thanks

**Tags:** templating, entries


---

## 1 answers

### Answer by username_1 on 2018-06-02. Score: 3 | Accepted answer

Your entry.expiration is actually an object of type DateTime thus you'll have the full power of PHPs DateDiff functionality 
$interval = $datetime1->diff($datetime2);

In Twig this is something like 
{% set difference = now.diff(entry.expiration) %} 
{{ difference.format('%R%a days') }} 

now should be the current date


---

