0

Based on the suggestions I received, I am converting epoch time to .NET DateTime by doing the following:

 string unixDate = "/Date(1395780377459)/";
 var datestring = unixDate.Substring(6).TrimEnd(')', '/');
 var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
 var result =  epoch.AddMilliseconds(long.Parse(datestring));

It is giving the correct result. But the code seems hacky to me. Is there a cleaner way to do this?

Community
  • 1
  • 1
softwarematter
  • 26,673
  • 61
  • 165
  • 257

0 Answers0