这很奇怪,我不太确定为什么它会按分钟递增.
您可以通过从日期获取年/月/日/小时/分钟组件值,然后使用这些组件来创建另一个日期,从而获得您想要的结果:
let value: Date? = Date()
if let date = value{
var calendar = Calendar.current
print(date.description(with: .current))
let components = calendar.dateComponents([.year, .month, .day, .hour, .minute], from: date)
if let mdate = calendar.date(from: components) {
print(mdate.description(with: .current))
}
}