summaryrefslogtreecommitdiff
path: root/includes/inc_utils.php
diff options
context:
space:
mode:
authorTheTroll <trolldev@gmail.com>2010-02-26 17:06:09 +0100
committerTheTroll <trolldev@gmail.com>2010-02-26 17:06:09 +0100
commit5779611e7d547302ed9847448acce65e07439b3d (patch)
tree76322b1e4015761ac92b21a85f1c06f7964863eb /includes/inc_utils.php
parentc11a6fccfe76152f1bf0e26bbe2af3cf81d91c34 (diff)
downloadistreamdev-5779611e7d547302ed9847448acce65e07439b3d.tar.gz
istreamdev-5779611e7d547302ed9847448acce65e07439b3d.tar.bz2
Display more media info (#268)
Display thumbs with the right A/R (#269)
Diffstat (limited to 'includes/inc_utils.php')
-rwxr-xr-xincludes/inc_utils.php35
1 files changed, 35 insertions, 0 deletions
diff --git a/includes/inc_utils.php b/includes/inc_utils.php
index 071d8b0..82b57a6 100755
--- a/includes/inc_utils.php
+++ b/includes/inc_utils.php
@@ -56,5 +56,40 @@ function php2js ($var)
return false;
}
+function sec2hms ($sec, $padHours = false)
+{
+
+ // holds formatted string
+ $hms = "";
+
+ // there are 3600 seconds in an hour, so if we
+ // divide total seconds by 3600 and throw away
+ // the remainder, we've got the number of hours
+ $hours = intval(intval($sec) / 3600);
+
+ // add to $hms, with a leading 0 if asked for
+ $hms .= ($padHours)
+ ? str_pad($hours, 2, "0", STR_PAD_LEFT). ':'
+ : $hours. ':';
+
+ // dividing the total seconds by 60 will give us
+ // the number of minutes, but we're interested in
+ // minutes past the hour: to get that, we need to
+ // divide by 60 again and keep the remainder
+ $minutes = intval(($sec / 60) % 60);
+
+ // then add to $hms (with a leading 0 if needed)
+ $hms .= str_pad($minutes, 2, "0", STR_PAD_LEFT). ':';
+ // seconds are simple - just divide the total
+ // seconds by 60 and keep the remainder
+ $seconds = intval($sec % 60);
+
+ // add to $hms, again with a leading 0 if needed
+ $hms .= str_pad($seconds, 2, "0", STR_PAD_LEFT);
+
+ // done!
+ return $hms;
+
+}
?>