I've seen other answers, but they're not working for me for some reason.
I'm trying to get yesterday's date in a Perl script using the following code.
For future reference, today's date is November 12, 2015
my (undef, undef, undef, $mday,$mon,$year) = localtime();
my $prev_day = timelocal(0, 0, 0, $mday-1, $mon, $year);
(undef, undef, undef, $mday,$mon,$year) = localtime($prev_day);
$year += 1900;
print "Yesterday's Day: $mday, Month: $mon, Year: $year\n";
Except my output looks like this
Yesterday's Day: 11, Month: 10, Year: 2015.
I should be reading yesterday's date as Day: 11, Month: 11, Year: 2015
. Why is the month being subtracted?
Edit: This is different than the suggested answer because I'm wondering why local time seems to be writing the wrong month.