NSDateFormatter date problem
I am using the Tapku library for Date purpose. After selecting the date b开发者_如何学编程y using the DateFormatter. I am getting the date, It is working fine in India.But When client(US) checking the dates it gives the one day before the selected Date.
i have got same problem but solution is set the gmtTimeZone in your code.like this
in following method.. - (void)calendarMonthView:(TKCalendarMonthView *)monthView didSelectDate:(NSDate *)d {
NSTimeZone *gmt = [NSTimeZone timeZoneWithAbbreviation:@"GMT"];///set GMT Time
NSDateFormatter *df = [[[NSDateFormatter alloc] init]autorelease];
[df setTimeZone:gmt];
[df setDateFormat:@"MM-dd-yyyy"];
NSString *dateNTime = [NSString stringWithFormat:@"%@", [df stringFromDate:d]];
NSLog(@"%@",dateNTime);
}
Best way is to get locale and set default device/system locale. Refer Apple documentation http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/DatesAndTimes/DatesAndTimes.html
精彩评论