获取当前时间
NSDate * timeDate=[NSDate date];
NSDateFormatter *dateformatter=[[NSDateFormatter alloc] init];
[dateformatter setDateFormat:@"HH:mm:ss"];
//[dateformatter setDateFormat:@"HH-mm-ss"];
NSString * locationString=[dateformatter stringFromDate:timeDate];
textField.text = locationString;
NSCalendar * cal=[NSCalendar currentCalendar];
NSUInteger unitFlags=NSDayCalendarUnit|NSMonthCalendarUnit|NSYearCalendarUnit;
NSDateComponents * conponent= [cal components:unitFlags fromDate:timeDate];
NSInteger year=[conponent year];
NSInteger month=[conponent month];
NSInteger day=[conponent day];
NSString * nsDateString= [NSString stringWithFormat:@"%4ld年%2ld月%2ld日",year,month,day];
textField.text = nsDateString;
原文地址:http://blog.csdn.net/lu_ca/article/details/46532853