I'm try to get local time from device
nsdate will return the UTC time
when I convert with localtime zone the string will return current local time...
again I try to convert string to local date but it will return only UTC time
This is my code... how can I get Local time in NSDate...
NSDate *currentDate = [NSDate date];
NSLog(@"currentDate: %@", currentDate); // Result: currentDate: 2014-05-19 05:21:50 +0000
NSDateFormatter *dateFormatter2 = [[NSDateFormatter alloc] init];
[dateFormatter2 setTimeZone:[NSTimeZone localTimeZone]];
[dateFormatter2 setDateFormat:@"yyyy/MM/dd HH:mm:ss"];
NSString *strDate = [dateFormatter2 stringFromDate:currentDate];
NSLog(@"strDate: %@", strDate); // Result: strDate: 2014/05/19 10:51:50
NSDate *newDate = [dateFormatter2 dateFromString:strDate];
NSLog(@"newDate: %@", newDate); // Result: newDate: 2014-05-19 05:21:50 +0000
can any one help to get local datetime in NSDate