NSDate NSFormatter NSCalender 的使用
[fmt setDateFormat:@"yyyy/MM/dd hh:mm:ss:SSS"];
NSString *string=[fmt stringFromDate:nsDate];
NSDateFormatter *dateFormatter = [[[NSDateFormatteralloc] init] autorelease];
[dateFormatter setDateFormat:@"yyyyMMddhhmmssSSS"];
return [dateFormatter stringFromDate:[NSDate date]];
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDate *now;
NSDateComponents *comps = [[NSDateComponents alloc] init];
NSInteger unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSWeekdayCalendarUnit |
NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit;
now=[NSDate date];
comps = [calendar components:unitFlags fromDate:now];
int year=[comps year];
int week = [comps weekday];
int month = [comps month];
int day = [comps day];
int hour = [comps hour];
int min = [comps minute];
int sec = [comps second];