Use the Time::Local funtion and transfer the date into epoch seconds.  Minus the number of seconds in a day and transfer back to a  date format.  Search the archives, I think this has been covered recently.

        Eric




"I'd take you seriously but to do so would be an affront to your intelligence."

-- William F. Buckley --




>From: "Joseph C. Bautista" <[EMAIL PROTECTED]>
>To: Denham Eva <[EMAIL PROTECTED]>
>CC: ActivePerl@listserv.ActiveState.com
>Subject: Re: Date Problem minus-ing a day
>Date: Mon, 01 Aug 2005 14:00:54 +0300
>MIME-Version: 1.0
>Received: from listserv.activestate.com ([209.17.183.249]) by mc3-f4.hotmail.com with Microsoft SMTPSVC(6.0.3790.211); Mon, 1 Aug 2005 05:47:08 -0700
>Received: from listserv.activestate.com (localhost.localdomain [127.0.0.1])by listserv.activestate.com (8.12.10/8.12.10) with ESMTP id j71C0spw016629;Mon, 1 Aug 2005 05:01:15 -0700(envelope-from [EMAIL PROTECTED])
>Received: from smtp7.ActiveState.com (percolator.ActiveState.com[192.168.2.13])by listserv.activestate.com (8.12.10/8.12.10) with ESMTP idj71B2Tl2010476 for <ActivePerl@listserv.ActiveState.com>;Mon, 1 Aug 2005 04:02:29 -0700(envelope-from [EMAIL PROTECTED])
>Received: from smtp8.activestate.com (smtp8.activestate.com [192.168.2.82])by smtp7.ActiveState.com (8.12.10/8.12.10) with ESMTP id j71B2QxS055645for <ActivePerl@listserv.ActiveState.com>;Mon, 1 Aug 2005 04:02:26 -0700 (PDT)(envelope-from [EMAIL PROTECTED])
>Received: from web.host-center.net (ns.host-center.net [66.98.136.87])by smtp8.activestate.com (8.13.3/8.13.3) with ESMTP id j71B2NfU095395for <ActivePerl@listserv.ActiveState.com>;Mon, 1 Aug 2005 04:02:24 -0700 (PDT)(envelope-from [EMAIL PROTECTED])
>Received: from [127.0.0.1] ([62.215.219.222]) (authenticated (0 bits))by web.host-center.net (8.11.6/8.11.6) with ESMTP id j71B1NF04209;Mon, 1 Aug 2005 14:01:24 +0300
>X-Message-Info: JGTYoYF78jGm+SG4l6ZTakEltxp0asMKfzX8XSH84H0=
>X-ClientAddr: 62.215.219.222
>User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)
>X-Accept-Language: en-us, en
>References: <[EMAIL PROTECTED]>
>X-HostCenter-MailScanner-Information: Please contact [EMAIL PROTECTED] more information
>X-HostCenter-MailScanner: Found to be clean
>X-MailScanner-From: [EMAIL PROTECTED]
>X-PerlMx-Spam: CA, All, Gauge=IIIIIII, Probability=7%, Report='__C230066_P5 0,__CT 0, __CTE 0, __CT_TEXT_PLAIN 0, __HAS_MSGID 0,__MIME_TEXT_ONLY 0, __MIME_VERSION 0, __SANE_MSGID 0,__STOCK_CRUFT 0, __USER_AGENT 0'
>X-PMX-Version: CA 4.7.1.128075, Antispam-Engine: 2.0.3.2,Antispam-Data: 2005.8.1.6
>X-BeenThere: activeperl@listserv.ActiveState.com
>X-Mailman-Version: 2.1.4
>Precedence: list
>List-Id: Discussions relating to ActivePerl<activeperl.listserv.ActiveState.com>
>List-Unsubscribe: <http://listserv.ActiveState.com/mailman/listinfo/activeperl>, <mailto:[EMAIL PROTECTED]>
>List-Archive: <http://ASPN.ActiveState.com/ASPN/Mail/Browse/Threaded/activeperl>
>List-Post: <mailto:activeperl@listserv.ActiveState.com>
>List-Help: <mailto:[EMAIL PROTECTED]>
>List-Subscribe: <http://listserv.ActiveState.com/mailman/listinfo/activeperl>, <mailto:[EMAIL PROTECTED]>
>Errors-To: [EMAIL PROTECTED]
>Return-Path: [EMAIL PROTECTED]
>X-OriginalArrivalTime: 01 Aug 2005 12:47:08.0506 (UTC) FILETIME=[20D623A0:01C59697]
>
>dunno about posix but this might help you...
>
>my $TimeStamp = &getTimeStamp('sec', time - (24*60*60)); # 1 day =
>(24*60*60)
>
>print "$TimeStamp \n";
>
>sub getTimeStamp{
> my ($str, $time) = @_;
> my @dt = localtime($time);
> my $year = $dt[5]+1900;
> $year = ($year);
> my $month = $dt[4]+1;
> if (length($month) == 1) { $month = "0" . ($month) ; }
> $month = ($month);
> my $day = $dt[3];
> if (length($day) == 1) { $day = "0" . ($day) ; }
> my $hour = ($dt[2]);
> my $min = ($dt[1]);
> my $sec = ($dt[0]);
> my $timestamp;
> if ($str eq "day") { $timestamp = "$day" ;}
> if ($str eq "month"){ $timestamp = "$day/" . "$month" };
> if ($str eq "year") { $timestamp = "$day/" . "$month/" . "$year "
>};
> if ($str eq "hour") { $timestamp = "$day/" . "$month/" . "$year "
>. "$hour" };
> if ($str eq "min") { $timestamp = "$day/" . "$month/" . "$year "
>. "$hour:" . "$min"};
> if ($str eq "sec") { $timestamp = "$day/" . "$month/" . "$year "
>. "$hour:" . "$min:" . "$sec"};
> return $timestamp;
>}
>
>
>Denham Eva wrote:
>
>>Hello All
>>
>>I am trying to use the following to capture the date in the format
>>day+month+year ie 01082005.
>>
>>Here is my code:
>>
>>my $day = (strftime('%d%m%Y', localtime()) );
>>
>>However as this is a program to check a log with the filename
>>format
>>filename01082005.log, I need to minus a day ie yesterday's date.
>>
>>So I tried this
>>
>>my $day = (strftime('%d%m%Y', localtime())-1 );
>>
>>But this returns 01082004 instead of 31072005.
>>
>>Can anyone help?
>>
>>Regards
>>Denham
>>
>>_______________________________________________
>>ActivePerl mailing list
>>ActivePerl@listserv.ActiveState.com
>>To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>>
>>
>>
>
>--
>(`/\
>`=\/\ __...--~~~~~~~-._ _.-~~~~~~---...__ `=\/\ {=}
>\_/ \\ `=\/\ {=} Joseph C. Bautista \\
> `=\/\{=} I.N. Team Leader / OSS Engr \\ `=\/{=} FCCI
>Kuwait \\ \/ {=} (+63) 09277799999
> \\ \/ {=} (+965)9394038 \\
> \/_\_{=}__--~~~~~~~-._ _.-~~~~~~~~--...__\\ |\//)
>(..----~~~~~~~._\ | /_.~~~----------....._.|| |+==( INK
>)===========\\|//=======================+
>
>
>
>--
>This message has been scanned for viruses and dangerous content by
>host-center.net and is believed to be clean.
>
>_______________________________________________
>ActivePerl mailing list
>ActivePerl@listserv.ActiveState.com
>To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to