The debugDescription for Date always uses UTC. This is because, internally, Date is just an offset from a specific moment in time, and it has no knowledge of time zones. You have to use a DateFormatter if you want time zone-sensitive printing.
You used the formatter to create the date instance, but not to print it. The date printed is "2018-04-07 00:00 +0200", which is what you intended. It's just that it prints using UTC, which is 2 hours behind your local time zone, and that is 22:00 on the previous day.
To get a string form using your specified time zone, use formattierer.string(from: cg).
(I am writing from memory, so the exact method signature may be different.)
Cannot convert value of type 'String' to expected argument type 'Date'
then I tried:
let cc = formattierer.date(from: aSimpleDate)
let cg = String(cc!) and got the output:
Cannot invoke initializer for type 'String' with an argument list of type '(Date)'
Wasn't meant as criticism of the answer, but rather as strong warning.
There should not be any tutorials, answers, etc… out there that show this easy to make mistake because it is simply the wrong answer.
Sorry for my (too) strong wording.
PS: I have made this error many times because I copied stuff from Stackoverflow ;)
Uh, that's very wrong. Please always use yyyy-MM-dd.
Indeed. Also, if you’re going to use a fixed date format string, also fix the locale to en_US_POSIX. There’s a world of things that can go wrong otherwise. My response on your other thread explains the three valid ways to use DateFormatter.