How to convert UTC date string to local time (systemTimeZone)

后端 未结 5 1567
萌比男神i
萌比男神i 2020-12-17 17:38

Input String: June 14, 2012 - 01:00:00 UTC

Output Local String: Jun 13, 2012 - 21:00:00 EDT

I like to get the offset from

NSTimeZone* destin         


        
5条回答
  •  温柔的废话
    2020-12-17 17:50

    func timeConverter() -> 
    {
        let zone = TimeZone.current
        let sec = -TimeInterval(zone.secondsFromGMT(for: self)
        return Date(timeInterval: sec , since : self)
    }
    

提交回复
热议问题