如何在 Swift 2.0 中减少当前日期的几分钟

How to reduce few minutes for current date in Swift 2.0

如何从当前时间减少 510 分钟,然后将其存储为 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 并从日期中减去 10 分钟。

let now = NSDate()

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