Create date from yyyy-MM-dd'T'HH:mm:ssZ
<p>I have a function in which I pass a date:</p>

<pre><code>createDate("2016-12-24'T'17:12:33.0500")
</code></pre>

<p>and the definition</p>

<pre><code>func createDate(fromString: String) -&gt; NSDate {
    let dateFormatter = NSDateFormatter()
    dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
    guard let date = dateFormatter.dateFromString(fromString) else {
        return NSDate()
    }
    return date
}
</code></pre>

<p>For some reason I always get today's date instead of 24 december.</p>

<p>What am I doing wrong ?</p>