或者:
// 时间戳转为C#格式时间
private DateTime StampToDateTime(string time)
{
time = time.Substring(0, 10);
double timestamp = Convert.ToInt64(time);
System.DateTime dateTime = new System.DateTime(1970, 1, 1, 0, 0, 0, 0);
dateTime = dateTime.AddSeconds(timestamp).ToLocalTime();
return dateTime;
}这个奏效,前面那个有错误。
本文介绍了一种将时间戳转换为C#格式时间的方法。通过一个简单的函数实现从Unix时间戳到C# DateTime对象的转换,并确保结果符合本地时间。
2207

被折叠的 条评论
为什么被折叠?



