Meghdad
Meghdad

Reputation: 23

timestap time used in instagram API in c#

I've been cached response from instagram api.but response contains specular time format, that i didn't meet it anywhere.

"created_time":"1437648595",

and now my Question is:

How to convert it from this template (As String type) to System.DateTime type? tanx

Upvotes: 2

Views: 1357

Answers (2)

Soner Gönül
Soner Gönül

Reputation: 98740

Instagram uses this value as a Unix time, you can get this as a double first and you can use it as ;

DateTime dt = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
dt = dt.AddSeconds(1437648595).ToLocalTime();

It returns 23.07.2015 13:49:55 in my time zone which I currently in UTC+03:00.

Upvotes: 3

Tomáš Bajar
Tomáš Bajar

Reputation: 11

I think this post answers your question. How to convert a Unix timestamp to DateTime and vice versa?

The format that you have posted looks like Unix time. Start your searching from there ;)

Upvotes: 1

Related Questions