NSDate *date = [NSDate date];
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"yyyy-MM-dd hh:mm:ss"];
NSString *dateStr = [dateFormat stringFromDate:date];
[dateFormat release];
NSLog(@"The date is: %@", dateStr);
转载于:https://blog.51cto.com/roadofios/1136269