im dealing with dates, and i'm having problems getting my date back from a string, i simplified my problem here:
let date = NSDate()
let formatter = NSDateFormatter()
formatter.dateFormat = "dd-MM-YYYY"
formatter.stringFromDate(date)
formatter.dateFromString(formatter.stringFromDate(date))
And the output is: "25-05-2015" (Which is fine) "Dec 21, 2014, 12:00 AM" (???)
The problem there is that
Y
is forweekOfYear
. You have to use"dd-MM-yyyy"
You should change your dateFormat to make it work , YYYY is not correct.
You should use
yyyy
for the year, notYYYY
(which has a different meaning)(*) it's 22:00 because I'm in the +0200 timezone, so this result is effectively 2015-05-25 00:00:00 in my timezone