how convert unix timestamp to datetime
Your code is working just fine, as is. Here is a fiddle.
Everyone that is telling you to use AddSeconds
is wrong. The number you are giving us is clearly in milliseconds. There are 31,536,000 seconds in a year. 1415115303410 divided by 31536000 is 4487. There hasn't been 4,487 years passed since 1/1/1970.
use AddSeconds instead of AddMilliseconds
private static DateTime UnixTimeStampToDateTime(long unixTimeStamp)
{
System.DateTime dtDateTime = new System.DateTime(1970, 1, 1, 0, 0, 0, 0);
dtDateTime = dtDateTime.AddSeconds(unixTimeStamp);
return dtDateTime;
}
Just use DateTimeOffset
DateTimeOffset date = DateTimeOffset.FromUnixTimeSeconds(1415115303410)