none
Is there any way to get timezone abbreviations?

    Question

  • Hey guys,
    Is there any way to get the abbreviation of whatever the PC's local timezone is set to (for example, EST, EDT, etc.)?  I couldn't find any way to do it but maybe someone knows a way.

    Thanks.
    Saturday, November 01, 2008 2:51 AM

Answers

  • No.  .NET / Windows simply does not have this information in its time zone "database".

                Console.WriteLine(TimeZoneInfo.Local.DisplayName);  
                if (TimeZoneInfo.Local.IsDaylightSavingTime(DateTime.UtcNow))  
                    Console.WriteLine(TimeZoneInfo.Local.DaylightName);  
                else 
                    Console.WriteLine(TimeZoneInfo.Local.StandardName); 

    On my system gives:

    (GMT-05:00) Eastern Time (US & Canada)  
    Eastern Daylight Time 


    • Proposed as answer by Harry Zhu Wednesday, November 05, 2008 8:07 AM
    • Marked as answer by Harry Zhu Thursday, November 06, 2008 1:58 AM
    Saturday, November 01, 2008 3:57 PM
  •  There is a GUI Time Zone Edito tzEdit.exe. It is in one of Professional Windows Resource Kits. It does not have the abbreviations, though. But it will highlight the line in ListBox with your TimeZone. The reason for the lack of abbreviations may be that there is no universal standard, I think.
    AlexB
    Saturday, November 01, 2008 5:31 PM
  • Thanks for the replies.
    It is unfortunate that there are no abbrev. available.

    I always thought that the abbreviations for time zones were standardized but as I investigated this issue it seems that they are not.

    I guess my only option is the snippet that AlexBB supplied.  Though, in some cases it may result in strange looking abbreviations.  For example, looking at the timezone info in the registry:

    "AUS Central Daylight Time": ACDT
    "Cape Verde Daylight Time": CVDT
    "GMT Standard Time": GST

    I guess I have no other option though if I want abbreviations.

    I'm curious though, do non-Windows/.net systems have access to timezone abbreviations?  It seems to me to be a useful thing to have.

    Thanks for the help. :)
    • Proposed as answer by Harry Zhu Wednesday, November 05, 2008 8:08 AM
    • Marked as answer by Harry Zhu Thursday, November 06, 2008 1:59 AM
    Saturday, November 01, 2008 8:16 PM
  •  I don't think you will get ACDT with my method. It is a different property that extracts DayLight names. It is called DaylightName. If you use that property you will get ACDT. I used StandardName.
    AlexB
    Saturday, November 01, 2008 11:35 PM

All replies

  • No.  .NET / Windows simply does not have this information in its time zone "database".

                Console.WriteLine(TimeZoneInfo.Local.DisplayName);  
                if (TimeZoneInfo.Local.IsDaylightSavingTime(DateTime.UtcNow))  
                    Console.WriteLine(TimeZoneInfo.Local.DaylightName);  
                else 
                    Console.WriteLine(TimeZoneInfo.Local.StandardName); 

    On my system gives:

    (GMT-05:00) Eastern Time (US & Canada)  
    Eastern Daylight Time 


    • Proposed as answer by Harry Zhu Wednesday, November 05, 2008 8:07 AM
    • Marked as answer by Harry Zhu Thursday, November 06, 2008 1:58 AM
    Saturday, November 01, 2008 3:57 PM
  •  There is a GUI Time Zone Edito tzEdit.exe. It is in one of Professional Windows Resource Kits. It does not have the abbreviations, though. But it will highlight the line in ListBox with your TimeZone. The reason for the lack of abbreviations may be that there is no universal standard, I think.
    AlexB
    Saturday, November 01, 2008 5:31 PM
  •  Consider this:

                char[ ] delim = { ' ' };  
                string[ ] words = TimeZone.CurrentTimeZone.StandardName.Split ( delim, StringSplitOptions.RemoveEmptyEntries );  
                string abbrev = string.Empty;  
                foreach ( string chaStr in words )  
                {  
                    abbrev += chaStr[ 0 ];  
                }  
                Console.WriteLine ( abbrev );  
     
    // Output: EST 

    AlexB
    • Proposed as answer by Harry Zhu Wednesday, November 05, 2008 8:08 AM
    Saturday, November 01, 2008 7:07 PM
  • Thanks for the replies.
    It is unfortunate that there are no abbrev. available.

    I always thought that the abbreviations for time zones were standardized but as I investigated this issue it seems that they are not.

    I guess my only option is the snippet that AlexBB supplied.  Though, in some cases it may result in strange looking abbreviations.  For example, looking at the timezone info in the registry:

    "AUS Central Daylight Time": ACDT
    "Cape Verde Daylight Time": CVDT
    "GMT Standard Time": GST

    I guess I have no other option though if I want abbreviations.

    I'm curious though, do non-Windows/.net systems have access to timezone abbreviations?  It seems to me to be a useful thing to have.

    Thanks for the help. :)
    • Proposed as answer by Harry Zhu Wednesday, November 05, 2008 8:08 AM
    • Marked as answer by Harry Zhu Thursday, November 06, 2008 1:59 AM
    Saturday, November 01, 2008 8:16 PM
  •  I don't think you will get ACDT with my method. It is a different property that extracts DayLight names. It is called DaylightName. If you use that property you will get ACDT. I used StandardName.
    AlexB
    Saturday, November 01, 2008 11:35 PM
  • True.  In that case it would return "AUS Central Standard Time", ACST.  I was thinking of timezones that are currently going through daylight savings.
    Sunday, November 02, 2008 4:00 AM
  • Hello

    You can use this custom function that I have written but it will work only for english culture info

     

    private string ShortTimeZoneFormat(string timeZoneStandardName)
    {
    string[] TimeZoneElements = timeZoneStandardName.Split(' ');
    string shortTimeZone = String.Empty;
    foreach (string element in TimeZoneElements)
    {
    //copies the first element of each word
    shortTimeZone += element[0];
    }
    return shortTimeZone;
    }
     when you call it pass to it TimeZoneInfo.Local.StandardName
    then all will be good

    Cheers


    Momo
    Monday, August 17, 2009 7:41 PM