I am new to IOS development. I am using date in my application. When i tried to get the start date(i.e, 18-11-2012) of current week using NSCalendar, i am receiving a date which is one day previous than the actual date.i.e, 17-11-2012. But when convert the received date to string, it is displaying 18-11-2012. I dont know how to solve the issue. Please help me to solve the same ASAP.
Please find the code below:
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *weekComponents = [calendar components:NSWeekCalendarUnit | NSYearCalendarUnit fromDate:currentWeekStartDate];
currentWeekStartDate = [calendar dateFromComponents:weekComponents];
NSLog(@"Current week start date is :%@", currentWeekStartDate);
Here, currentWeekStartDate variable holds the current date. And the output i received is,
Current week start date is :2012-11-17 18:30:00 +0000
I had posted the code and the output i got. Please find the same.