Reputation: 39
I have a seconds variable. How to convert its content to hours, days and weeks?
{assign var="formin" value="{$sec/60}"}
{$formin}
Upvotes: 0
Views: 68
Reputation: 1271
You should use date object with date_format (ex. {$smarty.now|date_format:"%D"}) because you can use conversion specifiers with it. More about that here: https://www.smarty.net/docsv2/en/language.modifier.date.format.tpl
If you still want to convert seconds to weeks in your template you can put calculations in smarty brackets:
{$sec/60}
{$sec/(60*60*24)}
{$sec/(60*60*24*7)}
Optionaly you can use string_format to round it up (ex. {$sec/(60*60*24*7)|string_format:"%d"}): https://www.smarty.net/docsv2/en/language.modifier.string.format.tpl
Upvotes: 1