User Tools

Site Tools

blog:2023-05-31_c_convert_ulong_to_datetime



2023-05-31 C#: Convert ulong to DateTime

  • Convert ulong to DateTime
  • static DateTime GetDTCTime(ulong nanoseconds, ulong ticksPerNanosecond)
    {
        DateTime pointOfReference = new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Utc);
        long ticks = (long)(nanoseconds / ticksPerNanosecond);
        return pointOfReference.AddTicks(ticks);
    }
    
    static DateTime GetDTCTime(ulong nanoseconds)
    {
        return GetDTCTime(nanoseconds, 100);
    }

Source

TAGS

  • 84 person(s) visited this page until now.

Permalink blog/2023-05-31_c_convert_ulong_to_datetime.txt · Last modified: 2023/05/31 17:16 by jethro

oeffentlich