Re: Date function
- From: Sharif Islam <mislam@xxxxxxxxxxxxx>
- Date: Tue, 28 Nov 2006 16:04:56 -0600
K.J. 44 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.
You can use the Date::Format module.
use strict
use Date::Format;
my $yesterday = time() - ( 24 * 60 * 60 );
my $prefix= time2str("%Y-%m-%d", $yesterday);
# YYYY-MM-DD-RestOfFileName.txt
print $prefix."-RestOfFileName.txt"
.
- Follow-Ups:
- Re: Date function
- From: Brian McCauley
- Re: Date function
- From: Gunnar Hjalmarsson
- Re: Date function
- From: K.J. 44
- Re: Date function
- References:
- Date function
- From: K.J. 44
- Date function
- Prev by Date: Date function
- Next by Date: Re: Date function
- Previous by thread: Date function
- Next by thread: Re: Date function
- Index(es):
Relevant Pages
|
|