http://www.perlmonks.org?node_id=826747


in reply to How to get last month date period

As with most time and date manipulation, I recommend the Date::Manip module.

use Date::Manip; # this is the current month my $current = ParseDate("today"); # or = ParseDate("january 2010") or +whatever # now let's find the last day of the previous month $last_month_last_day = DateCalc(UnixDate($current, "%Y-%m"), "-1 day") +; # then we print the interval print UnixDate($last_month_last_day, "01 %b %Y - %d %b %Y\n");