c#中获取时间戳

/// <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();
}

 

posted @ 2023-05-09 10:57  左耳*  阅读(77)  评论(0编辑  收藏  举报