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
In reply to Re: Working with date
by edoc
in thread Working with date
by alk1000
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |