1 <?php
defined('SYSPATH') OR die('No direct access allowed.');
3 * Help class for converting seconds to readable string of days, hours etc
8 * Convert a given nr of sec to string,
9 * day, hour, minute, second
11 public static function to_string($t=0)
15 # translate the abbreviations
16 # seems weird but I suppose someone will want this anyway
19 $m = _('m'); // minute
20 $s = _('s'); // second
21 $negative = _("negative") . " ";
23 if (!$t) return "0$d 0$h 0$m 0$s";
31 $hrs = ($t / 3600) %
24;
32 $mins = ($t / 60) %
60;
36 if ($neg) $timestring .= $negative;
38 $timestring .= $days.$d;
39 if ($hrs ||
$mins ||
$secs) $timestring .= " ";
42 $timestring .= $hrs.$h;
43 if ($mins ||
$secs) $timestring .= " ";
46 $timestring .= $mins.$m;
47 if ($secs) $timestring .= " ";
49 if ($secs) $timestring .= $secs.$s;