Doarchive

[objective C ] NS Date 사용하기 본문

Mobile/iOS

[objective C ] NS Date 사용하기

오순발닦개 2021. 8. 26. 10:50
   





NSDate * disconnectTime = [NSDate date];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];

NSTimeZone *krTimeZone =[NSTimeZone timeZoneWithName:@"Asia/Seoul"];
[dateFormatter setTimeZone:krTimeZone];


//NSDate를 NSString으로 변환
NSString *str = [dateFormatter stringFromDate:disconnectTime];
728x90