【发布时间】:2019-04-13 07:12:35
【问题描述】:
我正在尝试从今天起 14 天内获取当天的数字。 我想使用这个数字,所以它必须是一个整数值。
但我没有找到提取所需信息的解决方案。所以我的问题是如何在 14 天内获得日期以便我可以使用它?
let daysToAdd = 14
let newDate = Calendar.current.date(byAdding: .day, value: daysToAdd, to: Date())
//This is where I want to get
print ("In 14 days it is \(day).\(month).\(year)
【问题讨论】:
-
用这段代码你得到 newDate 的价值是什么?
-
@NikunjKumbhani 2019-04-13 08:56:55.911178+0200
标签: ios swift xcode calendar dateformatter