in reply to Date in Filename

Whatever method you use, I recommend dates in the sortable format: "YYYY-MM-DD.hh-mm-ss".

my @now = localtime(); my $timestamp = sprintf("%04d-%02d-%02d.%02d-%02d-%02d", $now[5]+1900, $now[4]+1, $now[3], $now[2], $now[1], $now[0]); my $filename = "error.$timestamp.log";

--
[ e d @ h a l l e y . c c ]

Replies are listed 'Best First'.
Re: Re: Date in Filename
by sauoq (Abbot) on May 19, 2003 at 21:22 UTC

    I agree that dates should be in a sortable format.

    For filenames, I often use something like YYYYMMDD_HHMMSS-filename. It varies because sometimes I only need the date; sometimes I don't need seconds; etc.

    It doesn't much matter one way or the other, but I do think that, if human readablity is a goal, different separation characters for date components and time components are helpful. So, how about ISO 8601? YYYY-MM-DDTHH:MM:SS. Several CPAN modules already handle it...

    -sauoq
    "My two cents aren't worth a dime.";