I have a string containing date time in CTE format, I would want to convert to a datetime object and then get the date time in UTC format.
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", CultureInfo.InvariantCulture,
DateTimeStyles.None, out var date
);
var unSpecifiedKing = DateTime.SpecifyKind(date, DateTimeKind.Unspecified);
var utcDate = TimeZoneInfo.ConvertTimeToUtc(unSpecifiedKing, tzi);