Prevent error on invalid input date format

If $format_in is invalid, $date->format would throw a fatal PHP error. Thi patch fixes the problem.