Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

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

by particle (Vicar)
on Jul 03, 2001 at 00:24 UTC ( #93313=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 particle

i prefer
use POSIX; use constant DATETIME => strftime("%Y-%m-%d_%H-%M-%S", localtime);
this returns something like "2001-07-02_15-07-32"

i use this to name temp directories, like

my $tmpdir = $ENV{TMP} . '/' . basename $0 . '.' . DATETIME . '.' . $$
which gives me a uniquely named dir. then my named temp files are more human readable, because i don't need the date/time string in their names.


Log In?

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2016-10-23 08:10 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (300 votes). Check out past polls.