/// <summary> /// 获取当前时间戳 /// </summary> /// <param name="bflag">为真时获取10位时间戳,为假时获取13位时间戳.</param> /// <returns></returns> public static string GetTimeStamp(bool bflag = true) { TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0); string ret = string.Empty; if (bflag) ret = Convert.ToInt64(ts.TotalSeconds).ToString(); else ret = Convert.ToInt64(ts.TotalMilliseconds).ToString(); return ret; }
原文:http://novell.me/master-diary/2014-08-02/csharp-generate-timestamp.html
时间: 2024-10-09 16:02:08