# in MyApp::Util sub convert_datetime { my ( $self, $incoming_datetime ) = @_; my $new_dt; eval { $new_dt = DateTime::Format::ISO8601->parse_datetime( $incoming_datetime ); }; return undef if $@; # No error, now we can convert the date (not shown) }