You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
824 B
Plaintext

using System;
namespace BP.GPM.DTalk.DDSDK
{
/// <summary>
/// 时间戳
/// </summary>
public class TimeStamp
{
public static long Now()
{
return (long)((DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalSeconds);
}
public static DateTime ToDateTime(long timestamp)
{
return new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(timestamp);
}
public static string ToDateTimeString(long timestamp)
{
return new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(timestamp).ToString();
}
public static string ToDateTimeString(long timestamp, string format)
{
return new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(timestamp).ToString(format);
}
}
}