1
2
3
4
5
6
7
8
9
10
11
12
13
use POSIX qw( mktime strftime );

my @t = localtime time();
$t[4] -= 2;  # $t[4] is tm_mon
my $two_months_ago = mktime @t;

print "Two months ago: $two_months_ago\n";
print "  ", strftime( "%Y/%m/%d %H:%M:%S", localtime $two_months_ago ), "\n";

__END__

Two months ago: 1340981243
  2012/06/29 15:47:23