Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calculate the difference between two dates in smarty 3 template prestashop

I have to calculate a sale end time relative to today,

I have the sale end time variable in this format {%d/%m/%Y %H:%M:%S} e.g.:(31/07/2016 18:27:58).

What I'm trying to do is to show ends: 8 days 06:10:29.
I can't use php code in the template because I'm using smarty 3 and I'm not an expert in smarty.

like image 571
no_dir_rahou Avatar asked Jul 23 '16 16:07

no_dir_rahou


1 Answers

Change your date1 and date2 values

{assign var="date1" value= $smarty.now}
{assign var="date2" value= $smarty.now+20*24*60*60}

{assign var="dateDiff" value=$date2 - $date1}

{$dateDiff|date_format:'%Y-%m-%d %H:%M:%S'}
like image 183
sandip Avatar answered Nov 06 '22 10:11

sandip