in reply to checking for valid date
UPD: But this won't work for valid dates less than Jan 1 1970 and greater than Jan 19 2038. If you need to check dates outside this range, try Date::Manip.use Time::Local; my $date = ' 19990230'; # 30th Feb 1999 $date =~ s/\s+$//; $date =~ s/^\s*//; my ($year, $month, $day) = unpack "A4 A2 A2", $date; eval{ timelocal(0,0,0,$day, $month-1, $year); # dies in case of bad date + 1; } or print "Bad date: $@";
|
|---|