How can I calculate the number of days between two dates in Perl?

前端 未结 7 2307
长发绾君心
长发绾君心 2020-12-05 19:05

I want to calculate (using the default Perl installation only) the number of days between two dates. The format of both the dates are like so 04-MAY-09. (DD-MMM-YY)

I

7条回答
  •  抹茶落季
    2020-12-05 19:27

    Date::Calc has Decode_Date_EU (and US etc)

    #!/usr/bin/perl
    use Date::Calc qw(Delta_Days Decode_Date_EU);
    
    ($year1,$month1,$day1) = Decode_Date_EU('02-MAY-09');
    ($year2,$month2,$day2) = Decode_Date_EU('04-MAY-09');
    
    print "Diff = " . Delta_Days($year1,$month1,$day1, $year2,$month2,$day2);
    

提交回复
热议问题