2

I am working in crunchbase api. I have got result form Crunchbase api https://developer.crunchbase.com/docs. I did not able to parse given value of Created date and update date to Datetime format using C# enter image description here

anybody help me to fix this issue ??

Shyam sundar shah
  • 2,473
  • 1
  • 25
  • 40

1 Answers1

1

Those numbers are unix timestamps.

Lucky for you, conversion is pretty straightforward since they just represent the time passed in seconds since 01.01.1970

// create a new DateTime for the time timestamps start counting from 
var dt = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc);
var dtDateTime = dt.AddSeconds(myJson.created_at).ToLocalTime();

Where myJson.created_at is your extracted date time.

Now that you realize what these attributes are, consider this question and answers that explain how to convert a unix timestamp to a C# datetime automatically as part of JSON conversion. Note that question is kind of different, you want seconds and not milliseconds like in that answer.

Community
  • 1
  • 1
Benjamin Gruenbaum
  • 270,886
  • 87
  • 504
  • 504