//獲取日期date對應(yīng)月的第一天日期//獲取日期date對應(yīng)月的最后一天日期
+ (NSString *)getMonthFirstDayWithDate:(NSDate *)date format:(NSString *)aformat{
? ? NSDate *newDate = date;
? ? double interval = 0;
? ? NSDate *firstDate = nil;
? ? NSCalendar *calendar = [NSCalendar currentCalendar];
? ? BOOL bl = [calendar rangeOfUnit:NSCalendarUnitMonth startDate:& firstDate interval:&interval forDate:newDate];
? ? if (bl) {
? ? ? ? NSDateFormatter *myDateFormatter = [[NSDateFormatter alloc] init];
? ? ? ? [myDateFormatter setDateFormat:aformat];
? ? ? ? NSString *firstString = [myDateFormatter stringFromDate: firstDate];
? ? ? ? return firstString;
? ? }
? ? return @"";
}
+ (NSString *)getMonthLastDayWithDate:(NSDate *)date format:(NSString *)aformat{
? ? NSDate *newDate = date;
? ? double interval = 0;
? ? NSDate *firstDate = nil;
? ? NSDate *lastDate = nil;
? ? NSCalendar *calendar = [NSCalendar currentCalendar];
? ? BOOL bl = [calendar rangeOfUnit:NSCalendarUnitMonth startDate:& firstDate interval:&interval forDate:newDate];
? ? if (bl) {
? ? ? ? lastDate = [firstDate dateByAddingTimeInterval:interval - 1];
? ? ? ? NSDateFormatter *myDateFormatter = [[NSDateFormatter alloc] init];
? ? ? ? [myDateFormatter setDateFormat:aformat];
? ? ? ? NSString *lastString = [myDateFormatter stringFromDate: lastDate];
? ? ? ? return lastString;
? ? }
? ? return @"";
}