How can I convert string date to NSDate?

前端 未结 18 1681
花落未央
花落未央 2020-11-22 16:14

I want to convert \"2014-07-15 06:55:14.198000+00:00\" this string date to NSDate in Swift.

18条回答
  •  伪装坚强ぢ
    2020-11-22 16:52

    You can try this swift code

        let dateFormatter = DateFormatter()
        dateFormatter.dateFormat = "dd/MM/yyyy"//same as strDate date formator
        dateFormatter.timeZone = TimeZone(abbreviation: "GMT+0:00")//Must used if you get one day less in conversion
        let convertedDateObject = dateFormatter.date(from: strDate)
    

提交回复
热议问题