Hi guys. I hate to post this really nooby question here but here it is.
I’m trying to format a number into weeks, days and hours to display total run time in a dynamic signature but I’m not sure how to do it.
I have only been using php for 2 days and Java is more my forte.
I wrote this.
[php]
function formatTime($time) {
$seconds = $time / 1000;
$minutes = $seconds / 60;
$seconds %= 60;
$h = ($minutes / 60);
$minutes %= 60;
$d = ($h / 24);
$h %= 24;
$w = ($d / 7);
$d %= 7;
$s = $w == 1 ? “” : “s”;
$s1 = $d == 1 ? “” : “s”;
$s2 = $h == 1 ? “” : “s”;
return $w . " Week" . $s . “, " . $d . " Day” . $s1 . " and " . $h . " Hour" . $s2 . “.”;
}
[/php]
It doesn’t work though. I think I’m treating php too much like Java and haven’t understood something somewhere. Can anyone shed any light on where I’m going wrong?