use Time::Piece; my $t = localtime; printf "%.4d"."%.2d"x5, $t->year, $t->mon, $t->mday, $t->hour, $t->min, $t->sec;