-8
计算2个给定时间戳之间差异的代码。 Start_Time="2017-09-19 19:36:12.763"
End_Time="2017-09-19 19:36:22.72"
我想在上面两个时间戳之间考虑毫秒的差异。如何计算PERL中2个时间戳之间的差异
这是我的尝试:
#!/usr/bin/perl
use strict;
use warnings;
use Date::Parse;
use Date::Format;
$startdat = "2007-11-17 12:51:22";
$stopdate = "2007-11-17 12:52:22";
my ($years, $months, $days, $hours, $mins, $secs) = split /\W+/, $startdat;
my ($yeart, $montht, $dayt, $hourt, $mint, $sect) = split /\W+/, $stopdate;
my $times = timelocal($secs,$mins,$hours,$days,$months,$years);
my $timet = timelocal($sect,$mint,$hourt,$dayt,$montht,$yeart);
$time = $timet - $times;
print $time;
但是,这给了我一个错误:在@公司无法定位日期/ Parse.pm。
@abbasp:另外,请考虑给你的问题一个更好的标题。 –
@abbasp:我已经修复了您的代码格式。这可能值得阅读[Markdown帮助](https://stackoverflow.com/editing-help)。 –
@Borodin:无论OP更新了评论中的代码,我都编辑了这个问题,不幸的是,在我编辑过相同的代码之前,有人编辑了这个问题。这是问题。不过,我会按照你的意见。 – ssr1012