如何在swift 3中获取当前日期?

Moh*_*shi 4 nsdate nstimezone ios swift swift3

我想在Swift 3中获取用户的当前日期和时区.我在Swift 2.2中尝试了以下代码:

static var localTimeZoneAbbreviation: String { return NSTimeZone.localTimeZone().abbreviation!}
Run Code Online (Sandbox Code Playgroud)

Nir*_*v D 11

为了得到abbreviationNSTimeZone.

static var localTimeZoneAbbreviation: String { return  NSTimeZone.local.abbreviation(for: Date())! }
Run Code Online (Sandbox Code Playgroud)

获得最新信息Date.

let currentDate = Date()
Run Code Online (Sandbox Code Playgroud)