When a Doctrine query contains a datetime object this code will prevent htmlspecialchars failing