>  기사  >  백엔드 개발  >  C#에서 TimeZoneInfo 가져오기

C#에서 TimeZoneInfo 가져오기

黄舟
黄舟원래의
2017-03-01 10:43:501955검색

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;
                }
            }
        }


그 중 _user.TimeZoneInfoString이 데이터베이스에 저장됩니다

위는 TimeZoneInfo를 가져오는 내용입니다. C# 관련 내용은 PHP 중국어 홈페이지(www.php.cn)를 참고해주세요!


성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.