Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get timezone from properties in CultureInfo

I have a string, which contains a timestamp (yyyy-mm-dd hh:mm:ss). I can create a CultureInfo object based on other information I get. Therefore I know which country the timestamp is in. The timestamp is not in UTC/GMT.

Say the timestamp is from Indonesia (new CultureInfo("id-ID")) , meaning the string was created by code below or similar.

DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");

That means the string contains the local time in Indonesia. I know my timezone, but I don't know how to convert the Indonesian time to UTC/GMT, so I can use the UTC/GMT object in TimeZoneInfo. My own timezone may or may not be in the same timezone.

Is there anywhere, this information is connected?

CultureInfo has a lot of properties, surely some of them can be used to get timezone, somwhere?

I might add that I find the entire system very confusing, so I could be way off in how I think things works.

like image 468
CS. Avatar asked Aug 09 '09 21:08

CS.


1 Answers

Short answer: No

Long Answer: This is a 1 to many relationship between culture and timezone. For example: en-US - English, American contains 6 timezones... so how would you get from en-US to Eastern Daylight time? ... and how do you get the daylight savings time offsets?

It's a confusing cultural conundrum (wow, try saying that 5 times fast) that is not easily solvable with the CLR.

like image 140
Jeff Fritz Avatar answered Sep 20 '22 16:09

Jeff Fritz