请教localtime函数输出

请教localtime函数输出

我想的得到的格式是“2008-9-19 02:03:23”,
但是用localtime()输出时得到的是“2008-9-19 2:3:23”
有哪指点一下或者有其他函数。部分源代码如下;

my ($a,$b,$c,$d,$e,$f) = localtime($atime_sec);
       $f=($f+1900);
       $e=($e+1);
       my  $atclrtime = "$f-$e-$d $cba"


[Copy to clipboard] [ - ]
CODE:
my  ($sec,$min,$hour,$mday,$mon,$year) = (localtime)[0..5];
($sec,$min,$hour,$mday,$mon,$year) = (
    sprintf("%02d", $sec),
    sprintf("%02d", $min),
    sprintf("%02d", $hour),
    sprintf("%02d", $mday),
    sprintf("%02d", $mon + 1),
    $year + 1900
);
print "$year-$mon-$mday $hour:$min:$sec\n";

哦,楼上的很强,虽然麻烦点。

[Copy to clipboard] [ - ]
CODE:
my  ($sec,$min,$hour,$mday,$mon,$year) = (localtime)[0..5];
$str = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $year+1900,$mon+1,$mday,$hour,$min,$sec);