I have a C# WPF User Interface and c back end. I'm receiving unix Timestamp in nanoseconds from the back end. Is there any way to convert that nanoseconds to human readable format?
Asked
Active
Viewed 2,408 times
1 Answers
0
Try this
public static DateTime UnixTimeStampToDateTime( double 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;
}
-
1Except the time stamp that the OP is receiving is in *nanoseconds*. You need to divide that value by 1,000,000,000 before calling `AddSeconds`. – Jim Mischel Apr 30 '15 at 22:21