I am converting an NSString with a date format of 2012-06-30 into an NSDate using the following code:
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd"];
NSDate *date = [dateFormatter dateFromString:dateString];
When omitting [dateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]] the value in NSString is 2012-06-29 23:00:00 plus some automatically added time zone information, which indicates that the the system has some assumptions about the current time zone.
The conversion works fine when I set the time zone with the method above.
However, what would happen if the user is in a different time zone?
How can I make sure that iOS parses just the date as it is and does not add any time information?
The data will not change, timezones dont affect that date itself, it just affect the date presentation, so a date that says 13:00 GMT will have the same presentation of a date that is 14:00 GMT +1
You shouldnt care about the timezones, instead for date conversion to the current time zone of the device use
This will set the time zone of the device