# get the seconds since epoch my $epoch = timelocal($seconds, $minutes, $hours, $mday, $mon, $year); # calculate the number of epoch seconds since requested days ago my $past_epoch = $epoch - $epoch_offset; # get the date of X (requested) days ago my $past_date = localtime($past_epoch);