<p>Date fields in Craft are returned as <code>DateTime</code> objects, so you need to convert these to a string to be able to compare them.</p>
<p>The best way of doing this is to use the <code>yyyy-mm-dd</code> format as this makes it is easy to compare dates.</p>
<p>So your comparison would become:</p>
<pre><code>   {% if (entry.dateUpdated|date('Y-m-d')) &gt;= (entry.postDate|date('Y-m-d')) %}
      Updated on {{ entry.dateUpdated.format('j M y') }}
   {% endif %}
</code></pre>

CC BY-SA 4.0
2020-11-16T09:47:26.147Z
That makes perfect sense. Just for reference there's a missing closing bracket - ie. (entry.postDate|date('Y-m-d'))
Andrew
CC BY-SA 4.0
2020-11-16T09:49:02.110Z
Thanks for picking that up. I've just edited it to correct it.
Steve Rowling
CC BY-SA 4.0
2020-11-13T11:54:17.480Z
2020-11-16T09:48:31.170Z
2020-11-16T09:48:31.170Z
Steve Rowling
<p>You're not checking against a valid field there - try using <code>entry.postDate</code> instead of <code>entry.post</code></p>

CC BY-SA 4.0
2020-11-13T11:53:02.077Z
2020-11-13T11:53:02.077Z
darylknight
<p>I want to display the date an entry has been updated if it is later than the post date. So I've tried this:</p>
<pre><code>   {% if entry.dateUpdated &gt;= entry.post %}
      Updated on {{ entry.dateUpdated.format('j M y') }}
   {% endif %}
</code></pre>
<p>But the date updated displays even if it is earlier. Is this because the date is not strictly a value as such?</p>

<datetime><postdate>
Displaying updated date for entry
# Displaying updated date for entry

(Asked by: username_0 on 2020-11-13)

I want to display the date an entry has been updated if it is later than the post date. So I've tried this:
   {% if entry.dateUpdated >= entry.post %}
      Updated on {{ entry.dateUpdated.format('j M y') }}
   {% endif %}

But the date updated displays even if it is earlier. Is this because the date is not strictly a value as such?

**Tags:** datetime, postdate

---

## 2 answers

### Answer by username_1 on 2020-11-13. Score: 2 | Accepted answer

Date fields in Craft are returned as DateTime objects, so you need to convert these to a string to be able to compare them.
The best way of doing this is to use the yyyy-mm-dd format as this makes it is easy to compare dates.
So your comparison would become:
   {% if (entry.dateUpdated|date('Y-m-d')) >= (entry.postDate|date('Y-m-d')) %}
      Updated on {{ entry.dateUpdated.format('j M y') }}
   {% endif %}

> **Comments:**
> **username_0**: That makes perfect sense. Just for reference there's a missing closing bracket - ie. (entry.postDate|date('Y-m-d'))  
> **username_1**: Thanks for picking that up. I've just edited it to correct it.  

---

### Answer by username_2 on 2020-11-13. Score: 1

You're not checking against a valid field there - try using `entry.postDate` instead of `entry.post`


---

