現在NSDate
NSDate *newdate = [NSDate date];
1.增加月份
NSDateComponents* dateComponents = [[NSDateComponents alloc]init];
[dateComponents setMonth:1];
NSCalendar* calendar = [NSCalendar currentCalendar];
NSDate* newDate = [calendar dateByAddingComponents:dateComponents toDate:“這邊填寫目前的NSDate” options:0];
1.減少月份
NSDateComponents* dateComponents = [[NSDateComponents alloc]init];
[dateComponents setMonth:-1];
NSCalendar* calendar = [NSCalendar currentCalendar];
NSDate* newDate = [calendar dateByAddingComponents:dateComponents toDate:“這邊填寫目前的NSDate” options:0];
0 意見:
張貼留言