[아이폰어플] date을 NSString로 변환

NSDate *today = [NSDatedateWithTimeIntervalSinceNow:0];

NSDateFormatter *dateFormat = [[[NSDateFormatteralloc] init] autorelease];

[dateFormat setDateStyle:NSDateFormatterShortStyle];

NSString *dateString = [dateFormat stringFromDate:today];

NSLog(@"Date: %@", dateString);

      //Date: 10/29/08

     // month/day/year


 // Output -> Date: 10/29/2008 08:29PM  NSDate *today = [NSDate date]; NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init]; [dateFormat setDateFormat:@"MM/dd/yyyy hh:mma"]; NSString *dateString = [dateFormat stringFromDate:today]; NSLog(@"date: %@", dateString); [dateFormat release];



출처 : http://blog.naver.com/PostList.nhn?blogId=philipousys¤tPage=24
Posted by 오늘마감

댓글을 달아 주세요