我无法从Date()获取特定时间。我在collectionView上有时间标签。我如何获得正确的时间?
此代码允许我获取完整数据
private func recordUser() {
let confirmationPayViewController = kMainStoryboard.instantiateViewController(withIdentifier: "EVConfirmationPayViewController") as! EVConfirmationPayViewController
confirmationPayViewController.modelController = MedicalRecordModelController()
guard let selectedIndexes = collectionView?.indexPathsForSelectedItems else { return }
print("selectedIndexes: \(selectedIndexes)")
for i in 0..<selectedIndexes.count {
let indexPath = selectedIndexes[i]
if indexPath.section == 1 {
let date = todaysTimes[indexPath.item].start
print("date: \(date)") // date: 2018-07-31 14:00:00 +0000
let df = DateFormatter()
df.dateFormat = "dd MMMM, HH:mm"
df.timeZone = TimeZone.current
df.locale = Locale(identifier: "ru_RU")
confirmationPayViewController.modelController.medicalRecord.date = df.string(from: date)
print("df2: \(df.string(from: date))") //df2: 31 july, 05:00
}
}
present(confirmationPayViewController, animated: true, completion: nil)
}