I'm trying to convert a date string into a NSDate. I have this input date string 2014-10-09 17:57
and this timezone +4
or Asia/Dubai
and for some reason, i get this NSDate after i execute the code below 2014-10-09 13:57:00 +0000
.
let dateString = "2014-10-09 17:57"
let formatter = NSDateFormatter()
formatter.dateFormat = "yyyy-MM-dd HH:mm"
formatter.timeZone = NSTimeZone(name: "Asia/Dubai")
println("\(formatter.dateFromString(dateString))")
I want to get a date like this 2014-10-09 17:57 +0400
. What am i doing wrong? Can you help me figure it out? I need the date to make some calculations between this one and another one which is correctly formatted with timezone.
It helps to breakup compound statements. The result of the formatter is a date, seconds since the reference date (GMT), it has no concept of a format or timezone.
The
println()
displays the date based ion the default formatting of there description method.If you want it display in a particular way use a date formatter to create the desired string representation.
Example: