将 UIDatePicker 设置为 1 小时后的当前时间

set UIDatePicker 1 hour later as current time

我认为标题说明了一切。 我可以获得当前时间,但我也需要当前时间 + 1 小时。

NSDate *today = [NSDate date];
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"dd MMM YYYY hh:mm"];
NSString *dateString = [dateFormat stringFromDate:today];
myUILabel.text = dateString; 

如何设置日期格式,使当前时间增加 1 小时?

NSDate *dateAfter_1hour = [NSDate dateWithTimeInterval:60*60 sinceDate:[NSDate date]];
UIDatePicker *datepicker = [[UIDatePicker alloc]init];
[datepicker setDate:dateAfter_1hour animated:YES];

在Swift中:

theDateAnHourFromNow = NSDate().dateByAddingTimeInterval(3600)