how to convert from prtime to .net datetime
Question
I want to convert a number that is in PRTime format (a 64-bit integer representing the number of microseconds since midnight (00:00:00) 1 January 1970 Coordinated Universal Time (UTC)) to a DateTime
.
Note that this is slightly different than the usual "number of milliseconds since 1/1/1970"
Solution
Dim prTimeInMillis as UInt64
prTimeInMillis = prTime/1000
dim prDateTime as new DateTime(1970, 1, 1)
prDateTime = prDateTime.AddMilliseconds(prTimeInMillis)
OTHER TIPS
DateTime has a constructor that takes Ticks (which are 100nanoseconds).
So take your prTime multiply it by 10 and add it to the number of ticks representing the Epoch time and you have your conversion.
private static DateTime epoch = new DateTime(1970, 1, 1);
private static DateTime ConvertPrTime(long time)
{
return new DateTime(epoch.Ticks + (time*10), DateTimeKind.Utc);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow