Skip to content

Instantly share code, notes, and snippets.

@phil-hudson
Created April 7, 2016 13:24
Show Gist options
  • Save phil-hudson/cf1fd720349453b7819dc9d7a0935203 to your computer and use it in GitHub Desktop.
Save phil-hudson/cf1fd720349453b7819dc9d7a0935203 to your computer and use it in GitHub Desktop.
import UIKit
func localizedDate() -> NSDate {
let now: NSDate = NSDate()
let timeZone: NSTimeZone = NSTimeZone.localTimeZone()
let secondsOffset = timeZone.secondsFromGMTForDate(now)
let localTimeZoneDate: NSDate = now.dateByAddingTimeInterval(Double(secondsOffset))
return localTimeZoneDate
}
print("Localized date")
print(localizedDate())
print("NSDate()")
print(NSDate())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment