Created
May 4, 2017 13:20
-
-
Save nkundu/c5ea9fedfe7dbd3ab9aa8785ad08eca9 to your computer and use it in GitHub Desktop.
Convert a unix time stamp to C# DateTime
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 DateTime UnixTimeStampToDateTime(int unixTimeStamp) | |
{ | |
// Unix timestamp is seconds past epoch | |
System.DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc); | |
dtDateTime = dtDateTime.AddSeconds(unixTimeStamp).ToLocalTime(); | |
return dtDateTime; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment