Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get current date in swift 3? [duplicate]

I want to get current date and time zone of user in Swift 3. I tried in Swift 2.2 following code :

static var localTimeZoneAbbreviation: String { return NSTimeZone.localTimeZone().abbreviation!}
like image 302
Mohsin Qureshi Avatar asked Dec 18 '22 13:12

Mohsin Qureshi


1 Answers

For getting abbreviation from NSTimeZone.

static var localTimeZoneAbbreviation: String { return  NSTimeZone.local.abbreviation(for: Date())! }

For getting current Date.

let currentDate = Date()
like image 58
Nirav D Avatar answered Jan 03 '23 21:01

Nirav D