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
  • 28,015
  • 64
  • 169
  • 263

0 Answers0