Skip to content

Instantly share code, notes, and snippets.

@nkundu
Created May 4, 2017 13:20
Show Gist options
  • Save nkundu/c5ea9fedfe7dbd3ab9aa8785ad08eca9 to your computer and use it in GitHub Desktop.
Save nkundu/c5ea9fedfe7dbd3ab9aa8785ad08eca9 to your computer and use it in GitHub Desktop.
Convert a unix time stamp to C# DateTime
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