#region 时间戳字符串
/// <summary>
/// 时间戳字符串
/// </summary>
/// <param name="dt">时间</param>
/// <returns>返回结果的字符串</returns>
public string GenerateTimeStamp(DateTime dt)
{
TimeSpan ts = dt.ToUniversalTime() - new DateTime(1970, 1, 1, 0, 0, 0, 0);
return Convert.ToInt64(ts.TotalSeconds).ToString();
}
/// <summary>
/// 时间戳字符串
/// </summary>
/// <param name="dt">时间</param>
/// <returns>返回结果的字符串</returns>
public string GenerateTimeStamp(DateTime dt)
{
TimeSpan ts = dt.ToUniversalTime() - new DateTime(1970, 1, 1, 0, 0, 0, 0);
return Convert.ToInt64(ts.TotalSeconds).ToString();
}
#endregion
/// <summary>
/// 时间戳
/// </summary>
/// <returns></returns>
public static string GetTime()
{
DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1, 0, 0, 0, 0));
DateTime nowTime = DateTime.Now;
long unixTime = (long)Math.Round((nowTime - startTime).TotalMilliseconds, MidpointRounding.AwayFromZero);
return unixTime.ToString();
}
/// 时间戳
/// </summary>
/// <returns></returns>
public static string GetTime()
{
DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1, 0, 0, 0, 0));
DateTime nowTime = DateTime.Now;
long unixTime = (long)Math.Round((nowTime - startTime).TotalMilliseconds, MidpointRounding.AwayFromZero);
return unixTime.ToString();
}