0

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?

Ashrith
  • 11
  • 2

1 Answers1

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;
}

Read this post

Community
  • 1
  • 1
sheshadri
  • 1,207
  • 9
  • 21
  • 1
    Except 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