Date matching in Swift not working code there : <p>iam trying to send some string dates to one method and if its matching the date format then return true,</p>

<p>my input paramters look like "4325/353/53" this is fail case and success case "09/25/2020"</p>

<p>my methode, but this is returning fail for everything. pls help</p>

<pre><code>func isValidDate(dateString: String) -&gt; Bool {
        let dateFormatterGet = DateFormatter()
        dateFormatterGet.dateFormat = "dd/MM/yyyy"
        if let _ = dateFormatterGet.date(from: dateString) {
            //date parsing succeeded, if you need to do additional logic, replace _ with some variable name i.e date
            return true
        } else {
            // Invalid date
            return false
        }
    } 
</code></pre>
