Get UTC time for a particular date and time in swift?
问题 Helllo all, I have a particular date & time selected from datepicker in iOS. i want to convert this date & time into UTC time.I have used below function for it. func get_Date_time_from_UTC_time(string : String) -> String { let dateformattor = DateFormatter() dateformattor.dateFormat = "yyyy-MM-dd HH:mm:ss" dateformattor.timeZone = NSTimeZone.init(abbreviation: "UTC") as TimeZone! let dt = string let dt1 = dateformattor.date(from: dt as String) dateformattor.dateFormat = "yyyy-MM-dd HH:mm:ss