Smarty Date & Time Compare
I can't for the life of me find a way to compare dates with times in a Smarty template.
The dates themselves work fine, and in the second, you add hours when it crashes:
{if $smarty.now|date_format:"%Y/%m/%d %H:%M" > '2015/12/10 12:00'}
greater 2015/12/10 12:00- {$smarty.now|date_format:"%Y/%m/%d %H:%M"}
{else}
smaller 2015/12/10 12:00- {$smarty.now|date_format:"%Y/%m/%d %H:%M"}
{/if}
date_format is meant to wrap around strtotime, so the comparison should work with times as well as dates?
DATE works without issue:
{if $smarty.now|date_format:"%Y/%m/%d" > '2015/12/10'}
greater 2015/12/10- {$smarty.now|date_format:"%Y/%m/%d"}
{else}
smaller 2015/12/10- {$smarty.now|date_format:"%Y/%m/%d"}
{/if}
thank
+3
source to share
No one has answered this question yet
Check out similar questions: