Reputation: 11435
Quick question.
I have a string date: example var dateString = "17-02-2015"
I use:
var dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "dd-MM-yyyy"
var newDate = dateFormatter.dateFromString(dateString)
And I get the output: 2015-01-16 23:02:00 +0000
Why am I missing a day? Is it because of the time zone? (I am at +1, and in the date the timezone is 0?).
I also tryed setting the time zone:
dateFormatter.locale = NSLocale.currentLocale()
dateFormatter.timeZone = NSTimeZone.systemTimeZone()
But no success.
What am I missing?
Upvotes: 0
Views: 2889
Reputation: 236558
Thats the UTC time and it is correct considering the fact that your LocalTime is 1+
var dateString = "17-02-2015"
var dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "dd-MM-yyyy"
var newDate = dateFormatter.dateFromString(dateString)!
println(newDate.descriptionWithLocale(NSLocale.currentLocale())!)
Upvotes: 2