Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Answer: How do I incorporate a timestamp into a file name?

by mikeB (Friar)
on Jul 02, 2001 at 22:23 UTC ( #93268=categorized answer: print w/replies, xml ) Need Help??

Q&A > dates and times > How do I incorporate a timestamp into a file name? - Answer contributed by mikeB

# grab the current time my @now = localtime(); # rearrange the following to suit your stamping needs. # it currently generates YYYYMMDDhhmmss my $timeStamp = sprintf("%04d%02d%02d%02d%02d%02d", $now[5]+1900, $now[4]+1, $now[3], $now[2], $now[1], $now[0]); # insert stamp into constant portion of file name. # the constant portion of the name could be included # in the sprintf() above. my $fileName = "File$timeStamp.log";

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2016-09-25 13:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:







    Results (470 votes). Check out past polls.