码迷,mamicode.com
首页 > 其他好文 > 详细

get utc+8 当时时间

时间:2016-06-16 19:40:49      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:

 /// <summary>
        /// get utc+8 当时时间
        /// </summary>
        /// <returns></returns>
        public static DateTime GUTCA8()
        {
            string id = "China Standard Time";
            DateTime rst =  TryZoneTime(DateTime.Now,id);
            return rst;
        }

        public static DateTime TryZoneTime(  DateTime time, string  timeZoneId)
        {
            try
            {
                var timeZone = TimeZoneInfo.FindSystemTimeZoneById (timeZoneId);
                return TimeZoneInfo.ConvertTime(time, timeZone);
            }
            catch { }
            return time;
        }

 

get utc+8 当时时间

标签:

原文地址:http://www.cnblogs.com/runliuv/p/5591801.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!