Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> iOS

วิธีบวก 1 วันกับ Date ใน iOS/iPhone

Date แทนจุดเวลาเดียว ใช้ Calendar.current.date(byAdding:to:)

โค้ดใน Playground

let date = Date()
let addedDate = Calendar.current.date(byAdding: .day, value: 1, to: date)
print(addedDate ?? "")