计算星期

NSDateFormatter *inputFormatter = [[NSDateFormatter alloc] init];
[inputFormatter setDateFormat:@"yyyy-MM-dd 'at' HH:mm"];
NSDate *formatterDate = [inputFormatter dateFromString:@"2012-01-01 at 07:30"];
[inputFormatter release];
NSDateFormatter *outputFormatter = [[NSDateFormatter alloc] init];
[outputFormatter setDateFormat:@"HH:mm 'on' EEEE MMMM d"];
NSString *newDateString = [outputFormatter stringFromDate:formatterDate];
[outputFormatter release];
NSLog(@"%@", newDateString); //07:30 on Sunday January 1
 

你可能感兴趣的:(ios,iPhone)