blob: 38439bcad1267d3a63338f59ad264d3ee1bc8f95 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: modifier
* Name: duration
* Purpose: formats a duration from seconds
* -------------------------------------------------------------
*/
function smarty_modifier_duration($string)
{
$result=Array();
if($string > 60*60*24) {
$days = floor($string/(60*60*24));
$result[]="$days days";
$string = $string % (60*60*24);
}
if($string > 60*60) {
$hours = floor($string/(60*60));
$result[]="$hours hours";
$string = $string % (60*60);
}
if($string > 60) {
$mins = floor($string/(60));
$result[]="$mins minutes";
$string = $string % (60);
}
if($string > 0) {
$result[]="$string seconds";
}
return implode(' ',$result);
}
?>
|