I followed the example from here, however the year returned is always wrong, like 2000-01-01. Is there a way to simply append to Date() the time I'm passing in? So I have the time as string, this is the func:
// Converts String time (01:07 PM) to Date (2000-01-01 18:07:00 +0000)
func convertStringTimeToDate(item: String) -> Date {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "hh:mm a"
dateFormatter.amSymbol = "AM"
dateFormatter.pmSymbol = "PM"
let date = dateFormatter.date(from: item)
return date!
}
For example, time: 01:07 PM
would wrongly give me 1 Jan 2000, 01:07 PM
. The year has to be correct.