I am facing a problem while converting from date to string and string to date.
code is :
NSDate *date=[NSDate date];
NSDateFormatter *formatter=[[NSDateFormatter alloc] init];
[formatter setDateFormat:@"dd/MM/YYYY"];
NSString *dateString=[formatter stringFromDate:date];
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"dd/MM/YYYY"];
NSDate *date2 = [dateFormat dateFromString:dateString];
while printing it is displaying the different date.
Kindly help me
NSDate always returns in GMT. So
date2is right. Its in GMT. You can consider it as27/05/2011 00:00:00 +0530 IST. There is nothing wrong with this.Doing this should return in IST.
You can also get
date2like this,