The optimal thing about mktimeis that it will handle any time offset. It uses January = 0; and Year 2009 = 109 in this pattern. Thus, the print month is 1 and the full year is 1900.
use POSIX qw<mktime>;
my ( $year, $month, $day ) = split '-', $date;
my $three_day_prior = mktime( 0, 0, 0, $day - 3, $month - 1, $year - 1900 );
mktimeuseful for finding the last day of the month. You just go the next day the next day.
mktime( 0, 0, 0, 0, $month, $year - 1900 );
source
share