I want to get client timezone id from JavaScript to parse c# TimezoneInfo class.And Convert to utc time.And I have this
var timezone = String(new Date());
return timezone.substring(timezone.lastIndexOf('(') + 1).replace(')', '').trim();
Problem is some time it will javascript timezone return CST. Is there a proper way to get timezone id
and from the c#
TimeZoneInfo ZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(timeZoneIdFromJavascript);
return TimeZoneInfo.ConvertTimeToUtc(Datetime, ZoneInfo);'
TimeZoneInfo
uses Windows time zone identifiers. They are not going to match anything coming out of JavaScript. Please read the timezone tag wiki.TimeZoneInfo
.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With