如何在Swift 2.0中减less当前date的几分钟

如何从当前时间减less510分钟,然后将其作为date格式存储在Swift 2.0中?

 let now = NSDate() var reducedTime = ???? \\ Here I want 10 minutes reduced from current time. 

如果当前时间是02:20:00,那么reducedTime应该是02:10:00我怎样才能以最简单的方式做到这一点

您可以使用日历方法dateByAddingUnit,并从date中减去10分钟。

 let now = NSDate() let reducedTime = NSCalendar(calendarIdentifier: NSCalendarIdentifierGregorian)?.dateByAddingUnit(.Minute, value: -10, toDate: now, options: NSCalendarOptions())