-1
我想计算窗口下时间戳的时间差。给定时间戳的时间差
TT1 = 2013年8月16日23:59:59:785
TT2 = 2013年8月16日23:59:59:753
和outut应该是:000826.288000
我已经尝试下面的代码,但获得输出为16799588.000000。
但输出应该是000826.288000.请帮我正确的时间戳000826.288000。
use DateTime::Format::Strptime;
my $dp = DateTime::Format::Strptime->new(
pattern => '%Y/%m/%d %H:%M:%S:%3N'
);
# Create two DateTime objects
my $tt1 = $dp->parse_datetime('2013/08/16 23:59:59:753');
my $tt2 = $dp->parse_datetime('2013/08/16 23:59:59:785');
# The difference is a DateTime::Duration object
my $diff1 = $tt2 - $tt1;
#print " t1 and t2 are : $diff $tt1 and $tt2 \n";
my $diff = sprintf "%013.6f", $tt2 - $tt1;