Files
podnoms/server/Utils/DateUtils.cs
Fergal Moran 1a92ad80eb Feature switch
2018-03-14 10:50:57 +00:00

21 lines
600 B
C#
Executable File

using System;
namespace PodNoms.Api.Utils
{
public class DateUtils
{
public static DateTime ConvertFromUnixTimestamp(double timestamp)
{
DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
return origin.AddSeconds(timestamp);
}
public static double ConvertToUnixTimestamp(DateTime date)
{
DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
TimeSpan diff = date.ToUniversalTime() - origin;
return Math.Floor(diff.TotalSeconds);
}
}
}