# Only showing updated\_at if it is different from published\_at

**URL:** <https://forum.ghost.org/t/only-showing-updated-at-if-it-is-different-from-published-at/26887>\
**Category:** Developer help\
**Created:** [November 19, 2021, 3:45am UTC](https://forum.ghost.org/t/only-showing-updated-at-if-it-is-different-from-published-at/26887 "2021-11-19T03:45:09Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![HappyThoughts](https://avatars.discourse-cdn.com/v4/letter/h/c0e974/32.png) [@HappyThoughts](https://forum.ghost.org/u/HappyThoughts)\
**Post date:** [November 19, 2021, 3:45am UTC](https://forum.ghost.org/t/only-showing-updated-at-if-it-is-different-from-published-at/26887/1 "2021-11-19T03:45:09Z")

</div>

Is there a way within the HBS files to only show the updated\_at value if it differs from published\_at?

I currently use something like this.

```auto
Published: <time datetime="{{date format="YYYY-MM-DD"}}">{{date published_at}}</time>
{{#if updated_at}}
Updated: <time datetime="{{date format="YYYY-MM-DD"}}">{{date updated_at}}</time>
{{/if}}

```

It always displays the updated date, since updated\_at seems to always contain a value (the published\_at value), even if the post was never actually edited/updated.

Is there a way to use if statements or something within handlebars so that it only renders the updated\_at time if it’s actually been updated (or different from the published date if it must have a value)? I found [this CSS alternative](https://forum.ghost.org/t/display-modified-date-on-posts-template/15507/4) but that’s it…

Related:  
[https://forum.ghost.org/t/true-updated-at-compare-dates/5656/2](https://forum.ghost.org/t/true-updated-at-compare-dates/5656/2)

---

<div class="post-metadata">

**Author:** ![vikaspotluri123](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/vikaspotluri123/32/24_2.png) [@vikaspotluri123](https://forum.ghost.org/u/vikaspotluri123)\
**Post date:** [November 19, 2021, 6:36am UTC](https://forum.ghost.org/t/only-showing-updated-at-if-it-is-different-from-published-at/26887/2 "2021-11-19T06:36:21Z")

</div>

You can try the `{{match}}` helper. It’s not yet documented, but here’s an example:

```auto
{{#match updated_at "!=" published_at}}
...
{{/match}}

```

---

<div class="post-metadata">

**Author:** ![HappyThoughts](https://avatars.discourse-cdn.com/v4/letter/h/c0e974/32.png) [@HappyThoughts](https://forum.ghost.org/u/HappyThoughts)\
**Post date:** [November 19, 2021, 8:14am UTC](https://forum.ghost.org/t/only-showing-updated-at-if-it-is-different-from-published-at/26887/3 "2021-11-19T08:14:31Z")

</div>

> [@vikaspotluri123](#):
>
> `{{/match}}`

Thanks, that works perfectly. 👍

---

<div class="post-metadata">

**Author:** ![evanw](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/evanw/32/16273_2.png) [@evanw](https://forum.ghost.org/u/evanw)\
**Post date:** [January 4, 2022, 11:27pm UTC](https://forum.ghost.org/t/only-showing-updated-at-if-it-is-different-from-published-at/26887/4 "2022-01-04T23:27:39Z")

</div>

@vikaspotluri123 Thanks Vikas, this is super helpful!

I suspect that the comparison is running on the full date/time attribute, so it would see Jan 4, 2022 12:00:00 as being different than Jan 4, 2022 14:00:00. Do you know if it’s possible to do this type of check based only on the date and not the time?

---

<div class="post-metadata">

**Author:** ![vikaspotluri123](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/vikaspotluri123/32/24_2.png) [@vikaspotluri123](https://forum.ghost.org/u/vikaspotluri123)\
**Post date:** [January 5, 2022, 1:55am UTC](https://forum.ghost.org/t/only-showing-updated-at-if-it-is-different-from-published-at/26887/5 "2022-01-05T01:55:08Z")

</div>

You can use the date helper to compare 🙂

e.g. `{{#match (date published_at format="l") "!=" (date updated_at format="l")}}`

I haven’t actually tried this, but it should work in theory.

---

<div class="post-metadata">

**Author:** ![HappyThoughts](https://avatars.discourse-cdn.com/v4/letter/h/c0e974/32.png) [@HappyThoughts](https://forum.ghost.org/u/HappyThoughts)\
**Post date:** [January 5, 2022, 2:45am UTC](https://forum.ghost.org/t/only-showing-updated-at-if-it-is-different-from-published-at/26887/6 "2022-01-05T02:45:18Z")

</div>

Seems to work for me. Thanks! I was actually hoping for functionality like this originally. 🕶

---

<div class="post-metadata">

**Author:** ![evanw](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/evanw/32/16273_2.png) [@evanw](https://forum.ghost.org/u/evanw)\
**Post date:** [January 5, 2022, 6:26am UTC](https://forum.ghost.org/t/only-showing-updated-at-if-it-is-different-from-published-at/26887/7 "2022-01-05T06:26:37Z")

</div>

@vikaspotluri123 Vikas, you beautiful genius, that worked perfectly. Thank you!
