in reply to I have seen a bug of Time::Local module

Time::Local is meant to be the inverse of the built-in localtime, therefore its arguments are of the same format with a month in a 0-11 range.

Additionally, you can use POSIX and strftime to get the timestamp in the format you want instead of rolling your own solution as it also takes datetime information in the same format as returned by localtime.

#!/usr/bin/perl -w use POSIX qw(strftime); use Time::Local; use strict; my @now = localtime(); my $timestamp = strftime "%Y%m%d%H%M%S", @now; print "$timestamp\n"; my $systime = timelocal(@now); print "$systime\n";
And if you really want to be succinct, you don't even really need Time::Local in this instance.
my $systime = time; my $timestamp = strftime "%Y%m%d%H%M%S", localtime $systime;

Replies are listed 'Best First'.
Re^2: I have seen a bug of Time::Local module
by chineseperlmonks (Initiate) on Apr 02, 2011 at 08:01 UTC
    I have solved the problems using the above methods. Thank you very much for all your replies!