Skip to content

Instantly share code, notes, and snippets.

@rskull
Created September 11, 2011 10:00
Show Gist options
  • Save rskull/1209412 to your computer and use it in GitHub Desktop.
Save rskull/1209412 to your computer and use it in GitHub Desktop.
9500秒を何時間何分何秒に変換
<?php
//秒を時間に変換
function oclock ($s) {
$h = 0;
$m = 0;
while ($s >= 60) {
if ($s >= 3600) {
$s -= 3600;
$h++;
} else {
$s -= 60;
$m++;
}
}
return "{$h}時間{$m}分{$s}秒";
}
//9500秒を変換
echo oclock(9500);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment