Problem with datetimeformat in HubL

SOLVE
SimoneM
Contributor

Hi, this is a code of one our HubL: 

 

<h3>Ultimi articoli sul blog</h3>
{% set rec_posts = blog_recent_posts('default', 3) %}
<ul>
{% for rec_post in rec_posts %}
<li>
<div class="left-col">
{% if rec_post.featured_image %}
<div class="hs-featured-image-wrapper">
<a href="{{rec_post.absolute_url}}" title="" class="hs-featured-image-link" alt="{{ rec_post.name }}">
<img src="{{ rec_post.featured_image }}" alt="{{ rec_post.name }}">
</a>
</div>
{% endif %}
</div>
<div class="right-col">
<h3><a href="{{ rec_post.absolute_url }}">{{ rec_post.name }}</a></h3>
<span class="display-date"><i class="mkdff-icon-simple-line-icon icon-calender"></i><span>{{ content.publish_date_local_time | datetimeformat ('%e-%b-%Y') }}</span></span>
</div>
</li>
{% endfor %}
</ul>

 

With this code, on the bottom of this site: http://www.effettodomino.social/ all the blog posts seem that are published on 26 July 2016

Screenshot_1.png

 

What can be the problem?

Thank you 

0 Upvotes
1 Accepted solution

Accepted Solutions
DaniellePeters
Solution
Top Contributor

You need to use 

 

{{ rec_post.publish_date_local_time | datetimeformat ('%e-%b-%Y') }}

 

instead of

{{ content.publish_date_local_time | datetimeformat ('%e-%b-%Y') }}

because you are looping through "rec_post in rec_posts" not "content in contents"

View solution in original post

2 Replies 2
DaniellePeters
Solution
Top Contributor

You need to use 

 

{{ rec_post.publish_date_local_time | datetimeformat ('%e-%b-%Y') }}

 

instead of

{{ content.publish_date_local_time | datetimeformat ('%e-%b-%Y') }}

because you are looping through "rec_post in rec_posts" not "content in contents"

View solution in original post

SimoneM
Contributor

Thank you very much indeed, it works

 

Best,

Simone 

0 Upvotes