Nothing is lost in the process, everything is there. It's just you're understanding the print(date)
is not printing according to you, whereas if you print a date object it'll print the date in UTC format
See below example
let oldDate = Date()
let dateFormat = DateFormatter()
dateFormat.dateFormat = "dd/MM/yy HH:mm"
dateFormat.calendar = Calendar.current
let oldDateFormattedString = dateFormat.string(from: oldDate)
print("Old date string: \(oldDateFormattedString)")
print("Old date: \(oldDate)")
let anotherDateFormat = DateFormatter()
anotherDateFormat.dateFormat = "dd/MM/yy HH:mm"
anotherDateFormat.calendar = Calendar.current
let anotherDate = anotherDateFormat.date(from: oldDateFormattedString)
print("Ano date: \(anotherDate!)")
Console
Old date string: 30/11/17 16:35
Old date: 2017-11-30 11:05:47 +0000
Ano date: 2017-11-30 11:05:00 +0000
You can see when you print oldDate
and anotherDate
the o/p is almost same except for seconds which you didn't include in the date format string.
e.g. add these two lines at the end of the code
let anotherDateString = anotherDateFormat.string(from: anotherDate!)
print("Ano date string: \(anotherDateString)")
You will see your console as
Old date string: 30/11/17 16:41
Old date: 2017-11-30 11:11:51 +0000
Ano date: 2017-11-30 11:11:00 +0000
Ano date string: 30/11/17 16:41