use strict; use Time::Local; $_ = my $file = "050924102022.log"; # a sample file name my @tl_data; unshift @tl_data, $1 while ( s/(\d{2})// ); print join " ", @tl_data, $/; # just to check $tl_data[-2]--; # need to subtract one from month number # (Time::Local can handle year number as-is) my $file_time = timelocal( @tl_data ); print "$file_time (sec. since epoch) = " . scalar localtime( $file_tim +e ) . $/; printf( "%s is %d minutes old\n", $file, int((time()-$file_time)/60));
In reply to Re: Time/date calculation
by graff
in thread Time/date calculation
by darrengan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |