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

前端 未结 7 2304
长发绾君心
长发绾君心 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:37

    You could convert the dates into the long integer format, which is the number of seconds since the epoch (some date in 1970 I think). You then have two variables that are the dates in seconds; subtract the smaller from the larger. Now you have a time span in seconds; divide it by the number of seconds in 24 hours.

提交回复
热议问题