$Bill Luebkert wrote:
Moreno, Javier wrote:
Hi,
I had an issue trying to compare dates in format YYYY-MM-DD so what I did was strip them of the hyphen making them numbers and then compare them. I was just wondering if there is a way to do compare or math with dates on perl, and if so, what format is the one perl will take in as input?
You can D/L a Date module as noted already, but it's too simple for me to bother with a Date module.
use strict; use Time::Local;
$_ = '2004-08-05'; my @d = split /-/, $_; my $epoch = timelocal (0, 0, 12, $d[2], $d[1]-1, $d[0]-1900);
# now compare $epoch to any other epoch based date
my $epoch2 = time; if ($epoch >= $epoch2) { print "In future: $epoch, $epoch2\n"; } else { print "In past : $epoch, $epoch2\n"; }
__END__
--
SKYKING, SKYKING, DO NOT ANSWER.
_______________________________________________ ActivePerl mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
