Within my swift app I have an iso8601 date (2017-10-27T10:15:23Z) that I receive. I use the following for the DateFormatter dateFormat
yyyy-MM-dd'T'HH:mm:ssZ
I then am taking it and using another format to get just the hour/min.
h:mm a
The code is this
let formatter = DateFormatter()
formatter.locale = Locale(identifier: "en_US_POSIX")
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZ"
let nsDate = formatter.date(from: date)
formatter.dateFormat = "h:mm a"
print(formatter.string(from: nsDate!))
The date outputs
5:15 not 10:15 like I expect it to be. I've tried using a different final formats but the results are the same. What am I doing wrong?