Plus for those who are concerned about two processes generating the same filename within the same second, appending the PID will keep them unique.
--
hiseldl
"Act better than you feel"
# Here's the plain jane, use "localtime" version that # prepends "0" before all numbers that have only one digit my @time = localtime(); $time[4]++; # convert from 0 based index to 1 based index $time[5]-=100; # 2digits=subtract 100 or 4digits=add 1900 $time[$_] = $time[$_]<10? "0".$time[$_]:$time[$_] for (0..5); my $filename = $time[5].$time[4].$time[3].$time[2].$time[1].$time[0]; # If you have POSIX this is a good alternative use POSIX; # %Y = 4 digit year and %y = 2 digit year my $filename = strftime("%Y%m%d%H%M%S", localtime); # To make sure that the filename is unique even if the fname # is generated the same second, add the PID $filename .= ".".$$;
In reply to Timestamp as a Filename Collection by hiseldl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |