Subtract number of seconds in a day 86400 from time:

        ($sec,$min,$hour,$mday,$mon,$year,undef,undef,undef) = localtime(time - 86400);

        Will give you yesterday.

        Mutliply by 2 - 2 days ago, 3 - days ago, etc.

Wags ;)
-----Original Message-----
From: Troy May [mailto:[EMAIL PROTECTED]]
Sent: Sunday, April 07, 2002 18:04
To: Perl Beginners
Subject: Yesterday's date


What's the easiest way to get yesterday's date from localtime?  I need it in
this format:  (for today) "070402".

Here is the code used for today's date:

($sec,$min,$hour,$mday,$mon,$year,undef,undef,undef) = localtime();
$mon++;
$year %= 100;
$theDate = sprintf("%02u%02u%02u", $mday, $mon, $year);

Thanks.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to