use DateTime::Format::ISO8601; eval { $date = DateTime::Format::ISO8601->parse_datetime("20061730"); }; if ( $@ ) { print "ERROR: date not valid" };