I have a string containing date time in CET (Central European Time), I would want to convert to a datetime object and then get the date time in UTC (Coordinated Universal Time).
I tried below code, which does the conversion. But problem is around the day light saving change it considers the time as invalid due to the time change.
DateTime.TryParseExact
(
myDate, "yyyyMMdd HH:mm", CultureInfo.InvariantCulture,
DateTimeStyles.None, out var date
);
var tzi = TimeZoneInfo.FindSystemTimeZoneById("Central European Standard Time");
var unSpecifiedKing = DateTime.SpecifyKind(date, DateTimeKind.Unspecified);
var utcDate = TimeZoneInfo.ConvertTimeToUtc(unSpecifiedKing, tzi);
6