in reply to Working with date
I have to recommend looking at some date modules on cpan but there are a lot to choose from so if that is all you need to do, and all you'll ever need to do you could use something like this:
#!/usr/bin/perl -w use strict; my $time = time; my $date = date_format($time); print "Now: $date\n"; my $tendays = date_format( $time + ( 10 * 24 * 60 * 60 ) ); print "10 days from now: $tendays\n"; my $thirtydays = date_format( $time + ( 30 * 24 * 60 * 60 ) ); print "30 days from now: $thirtydays\n"; sub date_format{ my $seconds = shift; my @bits = localtime($seconds); $bits[4]++; $bits[5] += 1900; return sprintf "%02.0f-%02.0f-%04.0f %02.0f:%02.0f:%02.0f", ($bits[3 +],$bits[4],$bits[5],$bits[2],$bits[1],$bits[0]); }
my sprintf'n prolly isn't the best, but it seems to work..
cheers,
J
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Working with date
by sauoq (Abbot) on Jun 04, 2003 at 06:31 UTC | |
by edoc (Chaplain) on Jun 04, 2003 at 06:33 UTC | |
|
Re: Re: Working with date
by alk1000 (Initiate) on Jun 06, 2003 at 01:14 UTC |