發布時間:2020-11-30 10:43 作者:獨孤劍 閱讀:1132
using System; namespace ConsoleApp13 { class Program { static void Main(string[] args) { Console.WriteLine(GetLocalTime("1596865604")); Console.Read(); } /// <summary> /// Unix轉換本地時間 /// </summary> /// <param name="timeStamp">Unix時間戳</param> /// <returns></returns> public static DateTime GetLocalTime(string timeStamp) { long time = long.Parse(timeStamp + "0000000"); DateTime start = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1, 0, 0, 0, 0)); TimeSpan toCurrent = new TimeSpan(time); return start.Add(toCurrent); } } }
微信打賞, 微信掃一掃
支付寶打賞, 支付寶掃一掃
如果文章對您有幫助,歡迎給作者打賞