or download this
use POSIX qw(strftime);
@t = localtime;
...
print strftime("%Y%m%d-%H%M%S", @t); # logfile_20040914-151753
print strftime("%Y-%m-%d-%H%M%S", @t); # logfile_2004-09-14-151753
print strftime("%Y-%m-%d@%H-%M-%S", @t); # logfile_2004-09-14@15-17-53