Re: Date function
- From: Gunnar Hjalmarsson <noreply@xxxxxxxxx>
- Date: Tue, 28 Nov 2006 23:15:07 +0100
Sharif Islam wrote:
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"
Or you can stick to the builtin functions and the standard module Time::Local:
use Time::Local;
my $midnight = timelocal 0, 0, 0, (localtime)[3..5];
my ($d, $m, $y) = (localtime $midnight-40000)[3..5];
print 'Yesterday: ',
sprintf('%d-%02d-%02d', $y+1900, $m+1, $d), "\n";
Note that Sharif's solution doesn't address the DST problem.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
.
- References:
- Date function
- From: K.J. 44
- Re: Date function
- From: Sharif Islam
- Date function
- Prev by Date: Re: Date function
- Next by Date: Re: Date function
- Previous by thread: Re: Date function
- Next by thread: Re: Date function
- Index(es):
Relevant Pages
|
|