(see this example online: https://stackblitz.com/edit/date-fns-playground-zeitzonen?file=index.ts -> Console output)
Following situation, it is 11:54 AM:
// Setup
const dateString = "2020-08-30T11:54:48.200Z"; // <---- 11:54 AM
const tz = "Europe/Berlin";
const dateFormat = "d. MMM yyyy, E HH:mm";
const dateOptions = { locale: de };
As far as I format the date, it changes its time-zone and adds 2 more hours:
const parsedDate = parseISO(dateString);
const formattedDate = format(parsedDate, dateFormat, dateOptions);
// outputs: 30. Aug 2020, So. 13:54
const zonedDate = utcToZonedTime(dateString, tz);
// outputs: 2020-08-30T11:54:48.200Z
const formattedZonedDate = format(zonedDate, dateFormat, dateOptions);
// outputs: 30. Aug 2020, So. 13:54
The desired (correct) output would be 30. Aug 2020, So. 11:54
Where is my mistake? Does the initial dateString
have the correct time zone?