gpt4 book ai didi

iOS 从当前日期起一个月。

转载 作者:可可西里 更新时间:2023-11-01 05:03:57 25 4
gpt4 key购买 nike

我想从当前日期算起一个月。

下面是我所拥有的,它正在返回:4027-09-24 16:59:00 +0000。当前日期是正确的。这是怎么回事?

// Get todays date to set the monthly subscription expiration date
NSDate *currentDate = [NSDate date];
NSLog(@"Current Date = %@", currentDate);
NSDateComponents *dateComponents = [[NSCalendar currentCalendar] components:NSMonthCalendarUnit | NSDayCalendarUnit | NSYearCalendarUnit fromDate:currentDate];
dateComponents.month = dateComponents.month + 1;
NSDate *currentDatePlus1Month = [[NSCalendar currentCalendar] dateByAddingComponents:dateComponents toDate:currentDate options:0];
NSLog(@"Date = %@", currentDatePlus1Month);

最佳答案

试试这个:

// Get todays date to set the monthly subscription expiration date
NSDate *currentDate = [NSDate date];
NSLog(@"Current Date = %@", currentDate);

NSDateComponents *dateComponents = [NSDateComponents new];
dateComponents.month = 1;

NSDate *currentDatePlus1Month = [[NSCalendar currentCalendar] dateByAddingComponents:dateComponents toDate:currentDate options:0];
NSLog(@"Date = %@", currentDatePlus1Month);

关于iOS 从当前日期起一个月。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19336836/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com