在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
1 public double ConvertDateTimeInt(System.DateTime time) 2 { 3 double intResult = 0; 4 System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)); 5 intResult = (time - startTime).TotalSeconds ; 6 return intResult; 7 } 8 public DateTime ConvertIntDatetime(double utc) 9 { 10 System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)); 11 startTime = startTime.AddSeconds(utc); 12 startTime = startTime.AddHours(8);//转化为北京时间(北京时间=UTC时间+8小时 ) 13 return startTime; 14 } 15 16 17 18 19 调用方法 20 21 DateTime utcNow = DateTime.Now.ToUniversalTime(); 22 double utc= ConvertDateTimeInt(utcNow); 23 DateTime dtime = ConvertIntDatetime(utc);
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论