/// <summary> /// 获取时间戳 /// </summary> /// <param name="isMillisecond">是否需要毫秒</param> /// <returns>当前时间戳</returns> public static string GetTimeStamp(bool isMillisecond = false) { var ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0); var timeStamp = isMillisecond ? Convert.ToInt64(ts.TotalSeconds).ToString() : Convert.ToInt64(ts.TotalMilliseconds).ToString(); return timeStamp; }
标签:C#,timeStamp,ts,DateTime,获取,时间,var,ToString From: https://www.cnblogs.com/yellow3gold/p/17010241.html