ios - 如何以编程方式从 ios 中的当前日期计算下一个第 5 个工作日期
<p><p>您好,我使用过 NSDateComponents 但无法计算第 5 个日期</p>
<pre><code>NSDate *now = ;
NSCalendar *calendar = [ initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *dateComponents = ;
NSInteger weekday = ;
NSLog(@"Week %ld",(long)weekday);
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>您可以像这样使用 NSDateComponents 在某个时间间隔后获取下一个日期</p> <pre><code>NSDateComponents *dateComponents = ;
dateComponents.minute = 15; //to get time after 15 minutes
dateComponents.day = 5; //to get date after 5 days
//and similarly you can calculate date or time after hour, minute, seconds day, week, etc
NSDate *date = [ dateByAddingComponents:dateComponents toDate: options:0]
</code></pre></p>
<p style="font-size: 20px;">关于ios - 如何以编程方式从 ios 中的当前日期计算下一个第 5 个工作日期,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/29430560/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/29430560/
</a>
</p>
页:
[1]