Skip to content

Instantly share code, notes, and snippets.

Created November 6, 2012 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/7ba40a37a8d8f7b6f1fe to your computer and use it in GitHub Desktop.
Save anonymous/7ba40a37a8d8f7b6f1fe to your computer and use it in GitHub Desktop.
sub seconds_to_duration {
my $sec = shift;
$days = $sec/(24*60*60);
$hours = ($sec/(60*60))%24;
$min = ($sec/60)%60;
$sec = $sec%60;
$duration_str = sprintf("%02d", $hours) . ":" . sprintf("%02d", $min) . ":" . sprintf("%02d", $sec) ;
return $duration_str;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment