[Perl]日期转时间戳

There's more than one way to do it!
https://metacpan.org http://perlmonks.org
回复
头像
PerlMonk
渐入佳境
渐入佳境
帖子: 49
注册时间: 2016年09月19日 10:20
联系:

[Perl]日期转时间戳

帖子 PerlMonk »

代码: 全选

use Time::Local;

my $dt = "2016-11-21 09:09:00";
my @a  = split(/[^\d]/, $dt);

$a[1] -= 1;                        #月份 0~11
my $t1 = timelocal( reverse @a );
print "$t1";
这里09也没去掉开头的0,但最后结果仍是正确的。
回复

在线用户

正浏览此版面之用户: 没有注册用户 和 0 访客