I have a date like this : 2018-04-30T23:22:05+1000 and want to convert in to Date
Object
let formatter = DateFormatter()
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss:Z" // z, zz also still nil
let ss = formatter.date(from: "2018-04-30T23:22:05+1000")
print("VAL : \(ss)") // nil always
What is the correct format for +1000 values?
Also what locale i have to add to get exact date?
use your dateformat as zone - The long specific non-location format. Where that is unavailable, falls back to the long localized GMT format (“0000”).
//2018-04-30T23:22:05+1000
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZ"
instead of
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss:Z" // z, zz also still nil
full answer
let formatter = DateFormatter()
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZ"
let ss = formatter.date(from: "2018-04-30T23:22:05+1000")
print("VAL : \(ss)") // nil always