How can I get the difference of two timestamps using Perl?

后端 未结 3 1933
情深已故
情深已故 2021-01-29 06:15

Here i based one problem.. i have two timestamps with same format like (Tue Dec 14 18:23:19 2010 & Tue Dec 14 17:23:19 2010). how can i get the difference of two timestamps

3条回答
  •  借酒劲吻你
    2021-01-29 06:45

    use Date::Parse;
    
    
    my $t1 = 'Tue Dec 14 17:23:19 2010';
    my $t2 = 'Tue Dec 14 18:23:19 2010';
    
    my $s1 = str2time( $t1 );
    my $s2 = str2time( $t2 );
    
    print $s2 - $s1, " seconds\n";
    

提交回复
热议问题