Search code examples
c#asp.netdatetimetimestampinstagram-api

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


Solution

  • 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.