use Time::Local; ### this will get me the Unix time ### for the last day in May # get today's month and year my ($m, $y) = (localtime)[4,5]; # get next month's month and year my ($nm, $ny) = ($m == 11) ? (0, $y+1) : ($m+1, $y); # get noon on the first of next month my $next_month_noon = timelocal(0,0,12, 1,$nm,$ny); # subtract a day from it (86400 seconds) my $month_last_day = $next_month_noon - 86400;