Tuesday 23 June 2009 6:21:29 am
There are probably much neater solutions but if need be you can do something like:
{def $date_difference = sub( currentdate(), $node.object.published )
$days = floor( div( $date_difference, 86400 ) )
$hours_mins = mod( $date_difference, 86400 )
$hours = floor( div( $hours_mins, 3600 ) )
$mins = floor( div( mod( $hours_mins, 3600 ), 60) ) }
And display it with:
{$days} Days, {$hours} hours {$mins} minutes ago.
Of course, caching would cause the time to remain frozen. Plus you might want to add some logic to change Days to Day if there is only 1 etc.
|