I want to have in my DatePicker selected date, but I have a problem with lag of 2 hours.
// String From Date
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setTimeStyle:NSDateFormatterFullStyle];
[dateFormatter setDateStyle:NSDateFormatterFullStyle];
[dateFormatter setLocale:[NSLocale currentLocale]];
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss ZZZ"];
NSDate *dateSelected = [datePicker date];
NSString *dateChoisie = [dateFormatter stringFromDate:dateSelected];
NSDate *dateFinal = [dateFormatter dateFromString:dateChoisie];
NSLog(@"dateSelected = %@", dateSelected);
NSLog(@"dateChoisie = %@", dateChoisie);
NSLog(@"dateFinal = %@", dateFinal);
Result :
2011-10-15 00:16:11.129 QuickEvent[25459:707] dateSelected = 2011-10-14 22:20:05 +0000
2011-10-15 00:16:11.132 QuickEvent[25459:707] dateChoisie = 2011-10-15 00:20:05 +0200
2011-10-15 00:16:11.138 QuickEvent[25459:707] dateFinal = 2011-10-14 22:20:05 +0000
Try using this kind of formatting..
For an example you can apply TIME_ZONE_THAT_YOU_WANTED = -8 for New york timezone based time
Thanks, Arun.