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