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.
And if you really want to be succinct, you don't even really need Time::Local in this instance.#!/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";
my $systime = time; my $timestamp = strftime "%Y%m%d%H%M%S", localtime $systime;
In reply to Re: I have seen a bug of Time::Local module
by wind
in thread I have seen a bug of Time::Local module
by chineseperlmonks
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |