Reputation: 8426
DateFormatter is acting funny to me:
let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "MM'/'DD'/'YYYY"
var dateString = "09/28/1989"
var date = dateFormatter.dateFromString(dateString)
println(date)
Returns:
"Optional(1988-12-24 13:00:00 +0000)"
Any kind of help will be appreciated.
Upvotes: 0
Views: 156
Reputation: 2755
It looks like your date formatter is a bit off. "MM'/'DD'/'YYYY"
reads "Padded month / day of the year (not month) / year of the current week (so Jan 1-6 could overlap and add side-effects)"
I'm guessing that what you're aiming for is "MM'/'dd'/'yyyy"
, which reads "Padded month / padded day of month / year"
For reference, here's the currently-used Unicode Technical Standard that Apple documents as their standard for iOS 7+ and OSX 10.9+ here
Upvotes: 2