Warning: Undefined array key "action" in /home/bakers/html/entryreply.php on line 5

Warning: Undefined variable $output in /home/bakers/html/entryreply.php on line 50

Warning: Undefined array key "EntrySubject" in /home/bakers/html/entryreply.php on line 51

Warning: Undefined variable $logintext in /home/bakers/html/entryreply.php on line 97

Warning: Undefined variable $reply_name in /home/bakers/html/entryreply.php on line 103

Warning: Undefined variable $reply_email in /home/bakers/html/entryreply.php on line 104
Perturb.org - interesting technology related things from around the internet

Perlfunc: human_time()

This function will convert a time in seconds into a human readable time like "12 days 18 hours 22 minutes 33 seconds"

sub human_time {
    my $secs = shift();
    my $ret;

    if (int($secs / 31536000) > 0) { $ret .= int($secs / 31536000) . " years "; }
    if (int(($secs % 31536000) / 2628000) > 0) { $ret .= int(($secs % 31536000) / 2628000) . " months "; }
    if (int(($secs % 2628000) / 86400) > 0) { $ret .= int(($secs % 2628000) / 86400) . " days "; }
    if (int(($secs %  86400) / 3600) > 0) { $ret .= int(($secs %  86400) / 3600) . " hours "; }
    if (int(($secs %  3600) / 60) > 0) { $ret .= int(($secs %  3600) / 60) . " minutes "; }
    if (int($secs %  60) > 0) { $ret .= int($secs %  60) . " seconds "; }

    $ret =~ s/\s+$//;

    return $ret;
}


Note: Replies will be formatted with PHP Markdown Extra syntax.

Name: Email (Not Required):
 
Logged IP: 3.227.235.216
To prevent spam please submit by clicking the kitten: