How to get current date in swift 3?

13,490

For getting abbreviation from NSTimeZone.

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

For getting current Date.

let currentDate = Date()
Share:
13,490

Related videos on Youtube

Mohsin Qureshi
Author by

Mohsin Qureshi

Updated on September 14, 2022

Comments

  • Mohsin Qureshi
    Mohsin Qureshi over 1 year

    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!}
    
    • Ketan P
      Ketan P over 7 years
      are you want date and timezone separate ? sample code just return timezone.