C# 获取北京时间 (根据纪元时间(1970/1/1)转换为DateTime)

根据纪元时间(1970/1/1)转换为DateTime

WebClient wc = new WebClient();
s= wc.DownloadString("http://api.time.3023.com/time");
long t= Newtonsoft.Json.JsonConvert.DeserializeObject(s).stime;
DateTime dt197011 = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
long lsystemTime = long.Parse(t.ToString() + "0000000");
TimeSpan toNowTs = new TimeSpan(lsystemTime);
DateTime time= dt197011.Add(toNowTs);
MessageBox.Show(time.ToString());

 class BeijingTime {
    public long stime { get; set; }
}

转载于:https://www.cnblogs.com/wgscd/p/6804441.html

你可能感兴趣的:(C# 获取北京时间 (根据纪元时间(1970/1/1)转换为DateTime))