0

I am having a problem regarding timezone conversion in C#.

From MySQL database we are getting timezone names as "US/EASTERN", while in C# we can get TimezoneInfo by name as "Eastern Standard Time".

For example :

TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");

so how can i map "US/EASTERN" to "Eastern Standard Time" easily.

Should i need to create a local mapping table that maps "US/EASTERN" with "Eastern Standard Time"?

Panagiotis Kanavos
  • 120,703
  • 13
  • 188
  • 236
Devendra
  • 99
  • 2
  • 10
  • That's an IANA timezone name, the de-facto standard. Windows doesn't use the IANA timezone names. If you care about timezones you should use [NodaTime](http://nodatime.org/) which includes the standard timezone names and removes confustion about timezones, local time etc. – Panagiotis Kanavos Dec 12 '16 at 08:19
  • MySQL though can't store dates with timezones or offsets, while .NET offers a DateTimeOffset. What are you trying to do and where does the timezone come from? MySQL doesn't *always* used the IANA names – Panagiotis Kanavos Dec 12 '16 at 08:20
  • Thanks for the reply. what i got from mysql database is "US/EASTERN" but passing this into a third party webservice is throwing error.Webservice supports timezone name as "Eastern Standard Time", so before calling webservice i have to change the word "US/EASTERN" into "Eastern Standard Time".But there are a lot of timezone names, so i dont want to create a temp table for mapping his names. Is there any other way to resolve my problem? – Devendra Dec 12 '16 at 08:32
  • 1
    That's already answered in [How to translate between Windows and IANA time zones?](http://stackoverflow.com/questions/17348807/how-to-translate-between-windows-and-iana-time-zones) which shows how to use NodaTime to convert from one timezone name to another – Panagiotis Kanavos Dec 12 '16 at 08:36

0 Answers0