runliuv

runliuv@cnblogs

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
 /// <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;
        }

 

posted on 2016-06-16 17:58  runliuv  阅读(348)  评论(0编辑  收藏  举报