1. 显示当前的年月日+时间
NSDate* date = [NSDate date];
NSDateFormatter* formatter = [[[NSDateFormatter alloc] init] autorelease];
[formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss.SSS"]; //指定格式
2. 只显示当前的日期格式
NSDate* date = [NSDate date];
NSDateFormatter* formatter = [[[NSDateFormatter alloc] init] autorelease];
[formatter setDateFormat:@"yyyy-MM-dd"];
NSString* timerStr = [formatter stringFromDate:date];
3. 获取某段时间差,可以精确到微秒级别, 用于计算代码执行效率
//可以精确到微秒级别
uint64_t start = clock();
[_image drawInRect:CGRectMake(0, 0, 400, 300)];
uint64_t end = clock();
uint64_t drawTime = end - start;