2010-06-22 8 views

답변

4
NSDate *now = [NSDate date]; 
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; 
NSDateComponents *comps = [[NSDateComponents alloc] init]; 
[comps setHour:-3]; 
NSDate *threeHoursAgo = [calendar dateByAddingComponents:comps toDate:now options:0]; 
[comps release]; 
[calendar release]; 

은 내가 당신에게 (사용 NSDateFormatter을)를 NSString로 출력을 둡니다.

+0

멋진 THanks! 그것은 위대한 작품! – Kenneth

관련 문제