1
周
我使用树枝来产生这样基于
{% set current_date = 0 %}
{% for post in posts %}
{% if post.created_at|date("m Y") != current_createdat %}
{% set current_createdat = post.created_at|date("m Y") %}
<h1>{{post.created_at|date("m Y")}}</h1>
{% endif %}
{{ post.title }}
{% endfor %}
我怎样才能比较,如果日期是在同一周在树枝列表如何比较日期?
'{%如果DATE1 |日期( “YW”)==日期2 |日期( “YW”)%}'会更好,因为它包含格式化字符串中的年份。否则,1950年的40周将被分类为与2000年第40周相同(很明显,其他许多)。 – qooplmao
嗨@qooplmao感谢您的注意!我看到一个关于这个建议使用'o'而不是'Y'作为年度比较的评论,[here](http://it2.php.net/manual/en/function.date.php#106974)详细的动机。你有什么想法? – Matteo
是的,这是有道理的,是一个很好的观点。 – qooplmao