# Updated Date on Blog

**URL:** <https://community.hubspot.com/t/updated-date-on-blog/31263>\
**Category:** CMS Development\
**Tags:** design-manager\
**Created:** [February 4, 2021, 12:27pm UTC](https://community.hubspot.com/t/updated-date-on-blog/31263 "2021-02-04T12:27:35Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![jw20](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jw20/32/29572_2.png) [@jw20](https://community.hubspot.com/u/jw20)\
**Post date:** [February 4, 2021, 12:27pm UTC](https://community.hubspot.com/t/updated-date-on-blog/31263/1 "2021-02-04T12:27:35Z")

</div>

I am editing our blog template to include an “_Updated on_” date. I have followed [this article](https://blog.hubspot.com/customers/writing-a-custom-updated-timestamp-for-blog-posts) (which has the code to copy missing) and it gets close, but it doesn’t completely work. It works when there’s an updated date, but when you first publish the post, it displays “_Published on February 3, 2021, updated on February 3, 2021_.” I want it to only show the “updated on” if the post is updated. The code from HubSpot is below. I don’t think I need the UTC offset because I’m not showing a time, but I’ve included it.

{% set update\_time = content.updated %}  
{% set offset = 14400000 %}  
{% set new\_time = update\_time - offset %}  
Published on {{ content.publish\_date|datetimeformat(‘%B %e, %Y’) }}  
{% if content.updated|unixtimestamp \> content.publish\_date|unixtimestamp %}  
, updated on {{ new\_time|datetimeformat(‘%B %e, %Y’) }}  
{% endif %}

I have also tried this - with the same result (updated date shows regardless if there was an update).

Published on {{ content.publish\_date|datetimeformat(‘%B %e, %Y’) }}  
{% if content.updated|unixtimestamp \> content.publish\_date|unixtimestamp %}  
, updated on {{ content.updated|datetimeformat(‘%B %e, %Y’) }}  
{% endif %}

Can anyone help with the syntax for the “if” so that the “updated on” only shows if the post is updated? I usually work in php and am just learning Hubl.

---

<div class="post-metadata">

**Author:** ![dennisedson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dennisedson/32/28044_2.png) [@dennisedson](https://community.hubspot.com/u/dennisedson)\
**Post date:** [February 5, 2021, 5:18pm UTC](https://community.hubspot.com/t/updated-date-on-blog/31263/2 "2021-02-05T17:18:51Z")

</div>

Hey @jw20

Welcome to the Community and congrats on getting into Hubl!

I think your time with PHP will serve you well here 😁

What I think you need is an if else statement instead of just an if statement

Read up on it [here](https://developers.hubspot.com/docs/cms/hubl/if-statements#using-elif-and-else)

@piersg is super well versed in all things Hubl and can probably lend a hand!

---

<div class="post-metadata">

**Author:** ![piersg](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/piersg/32/99782_2.png) [@piersg](https://community.hubspot.com/u/piersg)\
**Post date:** [February 5, 2021, 5:36pm UTC](https://community.hubspot.com/t/updated-date-on-blog/31263/3 "2021-02-05T17:36:15Z")

</div>

Hi @jw20 (thanks @dennisedson) and welcome! I think what you need is content.created, not content.publish\_date. So:

```lia-code-sample
Published on {{ content.created|datetimeformat('%B %e, %Y') }}
{% if content.updated|unixtimestamp > content.created|unixtimestamp %}
 , updated on {{ content.updated|datetimeformat('%B %e, %Y') }}
{% endif %}

```

---

<div class="post-metadata">

**Author:** ![dennisedson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dennisedson/32/28044_2.png) [@dennisedson](https://community.hubspot.com/u/dennisedson)\
**Post date:** [February 5, 2021, 5:40pm UTC](https://community.hubspot.com/t/updated-date-on-blog/31263/4 "2021-02-05T17:40:37Z")

</div>

Oops! Totally misread the question. Somehow I read it as

If not updated -- show Published on date

else show Updated on date.

Apologies for my misleading info 😥

---

<div class="post-metadata">

**Author:** ![jw20](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jw20/32/29572_2.png) [@jw20](https://community.hubspot.com/u/jw20)\
**Post date:** [February 5, 2021, 5:55pm UTC](https://community.hubspot.com/t/updated-date-on-blog/31263/5 "2021-02-05T17:55:10Z")

</div>

@dennisedson - you are correct - I want it to show “Published on Feb 2” OR “Published on Feb 2, updated on Feb 3”

@piersg your version still has the “updated on” showing, even when not updated. That’s the piece I need to work on.

I will keep trying. Thanks!

---

<div class="post-metadata">

**Author:** ![dennisedson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dennisedson/32/28044_2.png) [@dennisedson](https://community.hubspot.com/u/dennisedson)\
**Post date:** [February 5, 2021, 7:31pm UTC](https://community.hubspot.com/t/updated-date-on-blog/31263/6 "2021-02-05T19:31:57Z")

</div>

ok @jw20 , guess I am going to have to clean up @piersg 's mess 😜

```lia-code-sample
{% if content.updated|unixtimestamp > content.created|unixtimestamp %}
 Updated on {{ content.updated|datetimeformat('%B %e, %Y') }}
{% else %}
 Published on {{ content.created|datetimeformat('%B %e, %Y') }}
{% endif %}

```

---

<div class="post-metadata">

**Author:** ![jw20](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jw20/32/29572_2.png) [@jw20](https://community.hubspot.com/u/jw20)\
**Post date:** [February 5, 2021, 7:45pm UTC](https://community.hubspot.com/t/updated-date-on-blog/31263/7 "2021-02-05T19:45:26Z")

</div>

That’s a little big closer, @dennisedson -

When I publish a new post it says “Updated on Feb 5” - except it should say “Published on Feb 5”

The old posts that have been updated are correct and show the update date.

Does changing the content.created to content.published make a difference? Is content.created a draft?

Thanks,

Julie

---

<div class="post-metadata">

**Author:** ![dennisedson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dennisedson/32/28044_2.png) [@dennisedson](https://community.hubspot.com/u/dennisedson)\
**Post date:** [February 5, 2021, 8:31pm UTC](https://community.hubspot.com/t/updated-date-on-blog/31263/8 "2021-02-05T20:31:13Z")

</div>

By some coincedence, this was also discussed on the dev slack [here](https://hubspotdev.slack.com/archives/C2YH119N2/p1610720881020000)

Here is the code that finally worked (update with your copy)

```lia-code-sample
{% if content.updated|unixtimestamp//1000 > content.publish_date|unixtimestamp//1000 %}
 Originally posted on {{ content.publish_date_localized }}
 <br>Last updated on {{ content.updated_date_local_time|datetimeformat('%B %e, %Y') }}
{% else %}
 {{ content.publish_date_localized }}
{% endif %}

```

---

<div class="post-metadata">

**Author:** ![TShewchuk](https://avatars.discourse-cdn.com/v4/letter/t/a6a055/32.png) [@TShewchuk](https://community.hubspot.com/u/TShewchuk)\
**Post date:** [February 2, 2024, 4:06pm UTC](https://community.hubspot.com/t/updated-date-on-blog/31263/9 "2024-02-02T16:06:00Z")

</div>

![blog update date.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/3/7/37c9faa08e9e6f3d95a0dd484ec731822103d581.png)  
Hello! I tried inserting the code above into our blog template- since we want to be able to show when a blog was posted, as well as if it was updated. I’ve been playing around with it and can’t seem to find a solution where the time of orignially posted is not displayed. I just want to include date for originally posted and last updated. Any insight?

---

<div class="post-metadata">

**Author:** ![jw20](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jw20/32/29572_2.png) [@jw20](https://community.hubspot.com/u/jw20)\
**Post date:** [February 5, 2021, 9:11pm UTC](https://community.hubspot.com/t/updated-date-on-blog/31263/10 "2021-02-05T21:11:41Z")

</div>

Here is what I have:

```lia-code-sample
{% if content.updated|unixtimestamp//1000 > content.publish_date|unixtimestamp//1000 %} 
 Originally posted on {{ content.publish_date_local_time|datetimeformat('%B %e, %Y')}} <br>
 Last updated on {{ content.updated_date_local_time|datetimeformat('%B %e, %Y') }} 
{% else %} 
 Published on {{ content.publish_date_local_time|datetimeformat('%B %e, %Y') }} 
{% endif %} 

```

Of my four posts, they work - aside from one: it was updated yesterday at 4pm Eastern time, but is showing the update date as today.

Does something else need added as far as timezone? Something in the first line?

Thank you so much for the help!

---

<div class="post-metadata">

**Author:** ![jw20](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jw20/32/29572_2.png) [@jw20](https://community.hubspot.com/u/jw20)\
**Post date:** [February 6, 2021, 6:02pm UTC](https://community.hubspot.com/t/updated-date-on-blog/31263/11 "2021-02-06T18:02:34Z")

</div>

I updated how I had the time set up and it’s working perfectly.

Thanks for the assistance!

---

<div class="post-metadata">

**Author:** ![dennisedson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dennisedson/32/28044_2.png) [@dennisedson](https://community.hubspot.com/u/dennisedson)\
**Post date:** [February 8, 2021, 3:49pm UTC](https://community.hubspot.com/t/updated-date-on-blog/31263/12 "2021-02-08T15:49:31Z")

</div>

hey @jw20 ,

Mind adding your final code here and accepting it as the solution 🙏

---

<div class="post-metadata">

**Author:** ![jw20](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jw20/32/29572_2.png) [@jw20](https://community.hubspot.com/u/jw20)\
**Post date:** [February 8, 2021, 4:11pm UTC](https://community.hubspot.com/t/updated-date-on-blog/31263/13 "2021-02-08T16:11:14Z")

</div>

I changed the updated date from

`{{ content.updated_date_local_time|datetimeformat('%B %e, %Y') }}`

to

`{{ content.updated|datetimeformat('%B %e, %Y') }}`

Otherwise it showed the following day.

---

<div class="post-metadata">

**Author:** ![MLadenburg](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/mladenburg/32/2679_2.png) [@MLadenburg](https://community.hubspot.com/u/MLadenburg)\
**Post date:** [May 26, 2021, 9:01pm UTC](https://community.hubspot.com/t/updated-date-on-blog/31263/14 "2021-05-26T21:01:24Z")

</div>

@jw20 and @dennisedson ,

Thank you for your super helpful post. I’m trying to get mine to read “posted on,” unless it’s been updated so that it says, “updated on” - so basically overriding the “posted on.”  
Below is my code (largely copied and pasted from your efforts). At the moment, it posts both “posted on” and “updated on” - do you know what function would clear the original “posted on.”? Thank you for any help.

```lia-code-sample
<span class="hs-author-label">Posted on <a href="{{content.absolute_url}}">{{ content.publish_date_localized }}</a> by
 {%if content.blog_post_author %}</span><br>
 {%if content.updated|unixtimestamp//1000 > content.publish_date|unixtimestamp//1000 %}
 <br>Updated on {{ content.updated|datetimeformat('%B %e, %Y') }}
{% else %}
 {{ content.publish_date_localized }}
{% endif %}

```

---

<div class="post-metadata">

**Author:** ![jw20](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jw20/32/29572_2.png) [@jw20](https://community.hubspot.com/u/jw20)\
**Post date:** [May 26, 2021, 9:26pm UTC](https://community.hubspot.com/t/updated-date-on-blog/31263/15 "2021-05-26T21:26:06Z")

</div>

@MLadenburg - Unfortunately, I’m not any help. We ultimately didn’t add “Posted on” - although I don’t believe that I had gotten that to work either. The blog post displays the date and when updated, posts “Updated on” and the new date.

---

<div class="post-metadata">

**Author:** ![MLadenburg](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/mladenburg/32/2679_2.png) [@MLadenburg](https://community.hubspot.com/u/MLadenburg)\
**Post date:** [May 27, 2021, 4:40pm UTC](https://community.hubspot.com/t/updated-date-on-blog/31263/16 "2021-05-27T16:40:03Z")

</div>

@jw20 - Thanks for responding. Would you be willing to post the code in total? I’d love to get ours to do exactly that for the time being.

---

<div class="post-metadata">

**Author:** ![dennisedson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dennisedson/32/28044_2.png) [@dennisedson](https://community.hubspot.com/u/dennisedson)\
**Post date:** [May 27, 2021, 8:17pm UTC](https://community.hubspot.com/t/updated-date-on-blog/31263/17 "2021-05-27T20:17:50Z")

</div>

Hey @MLadenburg

Try this:

```lia-code-sample
{% if content.updated|unixtimestamp//1000 > content.publish_date|unixtimestamp//1000 %}
 Updated on {{ content.updated_date_local_time|datetimeformat('%B %e, %Y') }}

{% else %}
Posted on {{ content.publish_date_localized|datetimeformat('%B %e, %Y') }}
{% endif %}

```

@jw20 , what happened with yours? I just tested and this works 🤔

---

<div class="post-metadata">

**Author:** ![jw20](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jw20/32/29572_2.png) [@jw20](https://community.hubspot.com/u/jw20)\
**Post date:** [May 28, 2021, 10:58am UTC](https://community.hubspot.com/t/updated-date-on-blog/31263/18 "2021-05-28T10:58:50Z")

</div>

@dennisedson

I remember that if I updated the post at 4pm it would display as the next day. I don’t have time right now to dig through my notes, but neither of these worked for the “Updated” date - (I’m EST) if updated after 4pm -

`{{ content.publish_date_localized|datetimeformat('%B %e, %Y') }}`

`{{ content.updated_date_local_time|datetimeformat('%B %e, %Y') }}`

I ended up using this below, but the client decided not to include the words “Posted on”

`{{ content.updated|datetimeformat('%B %e, %Y') }} `

I’m sure it was some syntax issue on my end, but it was necessary to test across times and scenarios (like, saving a draft vs published) to double check it worked.

---

<div class="post-metadata">

**Author:** ![MLadenburg](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/mladenburg/32/2679_2.png) [@MLadenburg](https://community.hubspot.com/u/MLadenburg)\
**Post date:** [July 7, 2021, 9:46pm UTC](https://community.hubspot.com/t/updated-date-on-blog/31263/19 "2021-07-07T21:46:34Z")

</div>

@dennisedson and @jw20 ,

Thank you for all of your help! I tried @dennisedson 's code, but was really wanting the “posted on” and “updated on” written out - so was eventually able to get our dev’s eyeballs on it to help me out. I’m posting it here and a screenshot with how it looks in case anyone ever needs it!

```lia-code-sample
{% if content.updated|unixtimestamp//1000 > content.publish_date|unixtimestamp//1000 %}
 Updated on {{ content.updated_date_local_time|datetimeformat('%B %e, %Y') }}
 <br>Posted on {{ content.publish_date_localized }} by 
 {% if content.blog_post_author %}
 <a class="author-link" href="{{ group.absolute_url }}/author/{{ content.blog_post_author.slug }}">{{ content.blog_post_author.display_name }}</a>
 {% endif %}
 {% else %}
 Posted on {{ content.publish_date_localized }} by {% if content.blog_post_author %} <a class="author-link" href="{{ group.absolute_url }}/author/{{ content.blog_post_author.slug }}">{{ content.blog_post_author.display_name }}</a>
 {% endif %}
 {% endif %}

```

 ![Screen Shot 2021-07-07 at 2.44.33 PM.jpg](https://d2qpr2jzcazej7.cloudfront.net/original/3X/6/6/66165cdc237e7fca6ec95112b8a340871b7ab3b2.jpeg)

---

<div class="post-metadata">

**Author:** ![KeyWestScott](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/keywestscott/32/70903_2.png) [@KeyWestScott](https://community.hubspot.com/u/KeyWestScott)\
**Post date:** [May 17, 2022, 5:19pm UTC](https://community.hubspot.com/t/updated-date-on-blog/31263/20 "2022-05-17T17:19:55Z")

</div>

My word. Why in the world isn’t Hubspot simply making this an option? " Click here to show date of article update. "

All of Hubspot’s native articles show an “updated” date. Come on guys…

Scott.
