I'm having trouble parsing a date string in the PKT time zone.
Here is some code to paste in a playground:
import Foundation
let dateText = "Tue, 27 Jun 2017 04:00 AM PKT"
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "EEE, d MMM yyyy hh:mm a zzz"
if let checkDate = dateFormatter.date(from: dateText) {
let date = checkDate
print(date)
} else {
print("Could not parse")
}
If I change the time zone to "CDT" it works. However, I am trying to parse a date in Pakistan Standard Time (PKT) as that is the format I am parsing.
I found this handy tool and it says the format is invalid.
Using this table as a reference in formatting.
Documentation: https://developer.apple.com/documentation/foundation/nsdateformatter?language=objc
I see a references to similar questions How to get Current EST time IOS Swift