C#中获取TimeZoneInfo

黄舟
Libérer: 2017-03-01 10:43:50
original
1954 Les gens l'ont consulté

C#中获取TimeZoneInfo

public TimeZoneInfo TimeZoneInfo
        {
            get
            {
                var timeZoneInfoString = _user.TimeZoneInfoString;
                if (!string.IsNullOrEmpty(timeZoneInfoString))
                {
                    try
                    {
                        return TimeZoneInfo.FindSystemTimeZoneById(timeZoneInfoString);
                    }
                    catch (TimeZoneNotFoundException exception)
                    {
                        LogManager.GetLogger(GetType()).Error(exception);
                    }
                    catch (Exception exception)
                    {
                        LogManager.GetLogger(GetType()).Error(exception);
                    }

                    return TimeZoneInfo.Local;
                }
                else
                {
                    LogManager.GetLogger(GetType()).ErrorFormat("timeZoneInfoString for user {0} is empty", HttpContext.Current.User.Identity.Name);
                    return TimeZoneInfo.Local;
                }
            }
        }
Copier après la connexion


其中,_user.TimeZoneInfoString会存在数据库中

以上就是C#中获取TimeZoneInfo的内容,更多相关内容请关注PHP中文网(www.php.cn)!


Étiquettes associées:
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!