This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static readonly DateTime EpochUtc = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); | |
public static long ConvertDatetime2Timestamp(DateTime value) | |
{ | |
TimeSpan elapsedTime = value - EpochUtc; | |
return (long)elapsedTime.TotalSeconds; | |
} | |
public static DateTime ConvertTimestamp2Datetime(double timestampMilisec) | |
{ | |
DateTime dateTime = DateTime.SpecifyKind(EpochUtc, DateTimeKind.Utc); | |
return dateTime.AddSeconds(timestampMilisec); | |
} |
No comments:
Post a Comment