I have problems handling local time dates for my app in Swift. I would like to create today's Date at midnight and another instance at 23:59. Basically 2 dates to cover the whole current day (the idea is to load all of today's calendar entries). My code in playground:
import Foundation
let dateFormatter = DateFormatter()
let date = Date()
dateFormatter.dateFormat = "yyyy-MM-dd"
let todayStartDate = dateFormatter.date(from: dateFormatter.string(from: date))
let todayEndDate = dateFormatter.date(from: dateFormatter.string(from: Calendar.current.date(byAdding: .day, value: 1, to: date)!))
print(todayStartDate!)
print(todayEndDate!)
I end up having the time in there:
"Jan 27, 2018 at 12:00 AM"
Output of the print:
"2018-01-26 23:00:00 +0000\n"