Hi all,
I am converting NSString to NSDate with help of NSDateFormatter. Now code works fine here in all OS with device & simulator but it is creating different Output at UK, USA region. Here is the code that I am using.
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
NSString *dateString=[NSString stringWithString:@"2010-09-05 04:00:00"];
NSDate *dateObj = [dateFormatter dateFromString:dateString];
Actual date is : 2010-09-05 04:00:00
Output at USA : 2010-09-04 21:00:00 -0700
It seems the problem is at TimeZone/Locale somewhere but don't know the solution. I also tried :
[dateFormatter setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"GMT"]];
but couldn't get out of the issue.
Is there any simple way to get NSDate from NSString as the string actually represents without getting affected by TimeZone. I just want to get NSDate as it appears in NSString with No change in date & time. Is there any way? Thanks in advance.