in reply to File Timestamp Question

This is because the localtime function returns 0-based month. ie., 10th month is returned as 9. 1st month is returned as 0, and so on. To fix this, you just have to add 1 to the month.

And another observation is that you are not using sprintf to format your date, which makes it a bit messy.

Have a look at the following simpler version of get date, which uses sprintf to format number with leading 0.

sub Today() { my ($day, $month, $year) = (localtime)[3,4,5]; return sprintf "%04d%02d%02d", $year + 1900, $month+1, $day; }
Your code can be rewritten as
sub getdate { my ($min, $hr, $day, $mon, $yr) = (localtime($filedate))[1,2,3,4,5]; $filedate = sprintf "%02d-%02d-%04d", $mon+1, $day, $yr+1900; $filetime = sprintf "%02d:%02d:00", $hr, $min; }
cheers. Roger

Replies are listed 'Best First'.
Re: Re: File Timestamp Question
by ysth (Canon) on Oct 14, 2003 at 09:52 UTC
    see also POSIX::strftime
Re: Re: File Timestamp Question
by lisaw (Beadle) on Oct 14, 2003 at 00:34 UTC
    This is what I had thought too. But I noticed that it was also showing a '9' on the 10th "day" of each month. Before and after day "10" everything was showing the date fine.
      Are you sure? I tried it on my unix box and it worked perfectly.
      -rwxrwxr-x 1 rlee dev 4140 Oct 10 12:29 links.txt
      prints out
      12:29:00 10-10-2003