Re: Date function
- From: boyd <tbmoore9@xxxxxxxxxxx>
- Date: Tue, 28 Nov 2006 22:15:01 GMT
In article <1164750487.485271.239390@xxxxxxxxxxxxxxxxxxxxxxxxxxx>,
"K.J. 44" <Holleran.Kevin@xxxxxxxxx> wrote:
Hi,
is there a date function in Perl or do I have to try to find a module?
What i need is to be able to come up with the current date, then
subtract one day, and add that to the file name in the form of:
YYYY-MM-DD-RestOfFileName.txt
The script I have written parses these files and I want to run it every
night after midnight on the previous days file which has the naming
convention above.
I am running ActiveState Perl in a Windows environment.
Thanks.
There are built-in functions and modules, and numerous ones in the CPAN
library. I usually build this kind of thing myself, finding it quicker
than trying to find the right module.
something like:
my( $day, $mon, $yr ) = ( localtime( time - 24*3600) )[3, 4, 5];
$yr += 1900;
$mon += 1;
my $str = sprintf '%4d-%02d-%02d', $yr, $mon, $day;
would give you the prefix string for your filename.
Boyd
.
- Follow-Ups:
- Re: Date function
- From: Gunnar Hjalmarsson
- Re: Date function
- References:
- Date function
- From: K.J. 44
- Date function
- Prev by Date: Re: Validation with XSD using XML::LibXML::Schema, and XML::Validator::Schema
- Next by Date: Re: Date function
- Previous by thread: Re: Date function
- Next by thread: Re: Date function
- Index(es):
Relevant Pages
|