请帮忙换算PDT和UTC时间
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了请帮忙换算PDT和UTC时间相关的知识,希望对你有一定的参考价值。
June 13, 11:00am PDT- June13, 11:05am PDT
June 13, 06:00pm UTC- June 13, 06:05pm UTC
比如June 13, 11:00am PDT- June13, 11:05am PDT换算成UTC时间为June 13, 18:00pmUTC- June13, 18:05am UTC
UTC格式转换 & 十六进制换算为十进制
UTC格式转换成北京时间格式:
/// <summary> /// UTC格式与datatime的转换 /// </summary> /// <param name="utc"></param> /// <returns></returns> public DateTime ConvertIntDatetime(double utc) { System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)); startTime = startTime.AddSeconds(utc); startTime = startTime.AddHours(8);//转化为北京时间(北京时间=UTC时间+8小时 ) return startTime; }
十六进制换算为十进制:
/// <summary> /// 十六进制换算为十进制 /// </summary> /// <param name="strColorValue"></param> /// <returns></returns> public int GetHexadecimalValue(String strColorValue) { char[] nums = strColorValue.ToCharArray(); int total = 0; try { for (int i = 0; i < nums.Length; i++) { String strNum = nums[i].ToString().ToUpper(); switch (strNum) { case "A": strNum = "10"; break; case "B": strNum = "11"; break; case "C": strNum = "12"; break; case "D": strNum = "13"; break; case "E": strNum = "14"; break; case "F": strNum = "15"; break; default: break; } double power = Math.Pow(16, Convert.ToDouble(nums.Length - i - 1)); total += Convert.ToInt32(strNum) * Convert.ToInt32(power); } } catch (System.Exception ex) { String strErorr = ex.ToString(); return 0; } return total; }
以上是关于请帮忙换算PDT和UTC时间的主要内容,如果未能解决你的问题,请参考以下文章