时间戳转为C#格式时间 (互转)

来源:互联网 发布:三菱触摸屏编程软件 编辑:程序博客网 时间:2024/05/19 16:20
或者:
// 时间戳转为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;  }
这个奏效,前面那个有错误。