in reply to Find date 10 days before MM/DD/YY

For that, you're probably going to have to use localtime() and timelocal(). localtime() is a built-in function that takes a time - number of seconds since January first, 1970 - and returns an array that looks like:

($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)

timelocal() is part of the perl module Time::Local. It does the opposite of localtime, taking an array and returning the number of seconds since 1970. The easiest way I can think of to do what you want would be to extract the day, month, and year from your date, timelocal() it to get a number of seconds, subtract the number of seconds in ten days (10 days * 24 hours * 60 minutes * 60 seconds), then localtime it to get day, month, and year again. Something like this:

$date = (undef, undef, undef, $day, $month, $year);
$tenDaysPrevious = $date - 10*24*60*60;
(undef, undef, undef, $laterDay, $laterMonth, $laterYear) = timelocal($tenDaysPrevious);

See? Easy.

Replies are listed 'Best First'.
Re: Re: Date
by Anonymous Monk on May 28, 2001 at 08:33 UTC
    would u help me on finding the yesterday date.I have tried using the use::Format qw(time2str). And i want to run a file where to generate the data for last month. Infact all the possible date format i tried are not working. Please help.