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; }
}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM