Created
January 18, 2016 16:30
-
-
Save katopz/dc0f270d2ebc7ac20276 to your computer and use it in GitHub Desktop.
Crazy Timezone
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
// 2016 eh? | |
var dateString = "Fri Jan 01 00:00:00 +1100 2016" | |
let dateFormatter = NSDateFormatter() | |
dateFormatter.dateFormat = "E MMM dd HH:mm:ss Z yyyy" | |
let calendar = NSCalendar.currentCalendar() | |
let components = calendar.components([.Day , .Month , .Year], fromDate: dateFormatter.dateFromString(dateString)!) | |
print(components.year, components.month, components.day) | |
// na it's 2015 12 31 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment