您可以只获得所选日期的日期和月份,如下所示..
NSInteger sDay = [[[yourDatePicker date] stringFromDateWithFormat:@"dd"] integerValue];
NSInteger sMonth = [[[yourDatePicker date] stringFromDateWithFormat:@"MM"] integerValue];
if ( sMonth < 2 || (sMonth == 2 && sDay < 5) ) {
NSLog(@"yes its further");
}
以下是一种可用于将任何日期转换为任何日期格式的方法。
-(NSString*)stringFromDateWithFormat:(NSString*)strDateFormat{
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
//[formatter setTimeZone:[NSTimeZone systemTimeZone]];
[formatter setDateFormat:strDateFormat];
NSString *str = [formatter stringFromDate:self];
[formatter release];
return str;
}