public static DateTime UnixTimeStampToDateTime(long unixTimeStamp)
{
// Unix timestamp is seconds past epoch
DateTime dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
dateTime = dateTime.AddSeconds(unixTimeStamp);
return dateTime;
}
public static long UnixTimeStamp()
{
return UnixTimeStamp(DateTime.UtcNow);
}
public static long UnixTimeStamp(DateTime dt)
{
return new DateTimeOffset(dt).ToUnixTimeSeconds();
}
public static DateTime UTCStartOfDay()
{
var utc_date = new DateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month, DateTime.UtcNow.Day, 0, 0, 0, DateTimeKind.Utc);
return utc_date;
}