当前位置:首页 > Windows程序 > 正文

C# 如何生成一个时间戳

2021-03-11 Windows程序

/// <summary> /// 获取时间戳 /// </summary> /// <returns></returns> public static string GetTimeStamp() { TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0); return Convert.ToInt64(ts.TotalSeconds).ToString(); }

  主要用的类:DateTime, TimeSpan

温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/59403.html