use strict;
my $sec = 30028;
# result should be 08:20:28
my $time = &ConvertSeconds2Hours($sec);
print $time;
sub ConvertSeconds2Hours()
{
my $sec=shift;
my $hours = ($sec/3600);
my ($hours,$x) = split('\.', $hours);
if ($hours < 10)
{
$hours = "0" . $hours;
}
my $min = ($sec%3600);
$min = ($min/60);
my ($min,$x) = split('\.', $min);
if ($min < 10)
{
$min = "0" . $min;
}
$sec = ($sec%60);
if ($sec < 10)
{
$sec = "0" . $sec;
}
return "$hours:$min:$sec";
}
Custom Search
|
PayPal is the easiest way to receive money online. Get one now or Click here to sign up.
How to convert seconds into HH:MM:SS (24 hour format) using Perl
WebProNews Feed
Custom Search
|
eWeek - RSS Feeds
HowtoForge - Howtos and Tutorials
The Register
PayPal is the easiest way to receive money online. Get one now or Click here to sign up.
No comments:
Post a Comment