获取时间戳(毫秒级和秒级)
作者:互联网
/// <summary> /// 获取时间戳 /// </summary> /// <param name="bflag">true 秒 , false 毫秒</param> /// <returns></returns> public static string GetTimeStamp(bool bflag) { 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; }
标签:string,获取,ts,ret,bflag,毫秒,时间,ToString,DateTime 来源: https://www.cnblogs.com/yuanshuo/p/16482594.html