如何在 iPhone 的当前 NSDate 中添加一分钟并保存在 NSDate 中? [英] how can I add one minutes in current NSDate of iphone and save in NSDate?
本文介绍了如何在 iPhone 的当前 NSDate 中添加一分钟并保存在 NSDate 中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以通过此代码获取 iphone 的当前日期
I can get current date of iphone via this code as
NSDate *currentDate = [NSDate date];
NSDateFormatter *dateFormatter1 = [[NSDateFormatter alloc] init];
[dateFormatter1 setDateFormat:@"yyyy-MM-dd HH:mm"];
NSString *dateString = [dateFormatter1 stringFromDate:currentDate];
现在我只想增加一个薄荷然后保存NSString格式,我该怎么办?
Now I just want to increase one mint then save NSString format, how can I?
推荐答案
您可以使用 dateByAddingTimeInterval.
You can use dateByAddingTimeInterval.
NSDate *currentDate = [NSDate date];
NSDate *datePlusOneMinute = [currentDate dateByAddingTimeInterval:60];
//60 seconds
这篇关于如何在 iPhone 的当前 NSDate 中添加一分钟并保存在 NSDate 中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文