- 论坛徽章:
- 0
|
本帖最后由 黑色阳光_cu 于 2010-09-29 15:01 编辑
- sub convert_time
- {
- require Time::Local;
- my ($time_str) = @_;
- my $time;
- my $convert_month = sub
- {
- my %months =
- (
- Jan => 0,
- Feb => 1,
- Mar => 2,
- Apr => 3,
- May => 4,
- Jun => 5,
- Jul => 6,
- Aug => 7,
- Sep => 8,
- Oct => 9,
- Nov => 10,
- Dec => 11
- );
- return $months{$_[0]};
- };
- if ($time_str =~ /^\w+\s+(\w+)\s+(\d+)\s+(\d+):(\d+):(\d+)\s+(\d+)$/)
- {
- my ($month, $day, $h, $m, $s, $year) = ($convert_month->($1), $2, $3, $4, $5, $6);
- if (defined $month)
- {
- $time = Time::Local::timelocal($s, $m, $h, $day, $month, $year);
- }
- }
- return $time;
- }
- die convert_time("Tue Sep 28 18:40:19 2010");
复制代码 |
|