Display modified date on posts template

Hi everyone,

How can I display the modified date of a post if the created date is different of the modified date?

Best regards

Hey @Bruno_Sousa :wave:
The post object contains an updated_at value which is exposed in the handlebars theme #post context. Editing the post.hbs and adding {{updated_at}} helper should do the trick. More info can be found here:

Hi @DavidDarnes,

I tested that, but If the post is not modified the created date is the same as modified date. How can I check if the modified date is not the same as created date?

Best regards

That’s where some clever CSS can come in handy:

<style media="screen">
  .updated[datetime="{{published_at}}"] { display: none; }
</style>
<time class="updated" datetime="{{updated_at}}">Updated: {{updated_at}}</time>
<time class="published" datetime="{{published_at}}">Published: {{published_at}}</time>

The CSS here is selecting the updated date element with an attribute value of the published date and hiding it, it’ll only appear if the updated date is different to the published date :+1: