Вопрос

How do I get the current UTC time in ulong number of minutes since 01.01.2001 00:00 in c#? I know it involves DateTime.UtcNow property but how do I get the offset in minutes?

Это было полезно?

Решение

You can use:

ulong totalMinutes = (ulong) (DateTime.UtcNow - new DateTime(2001,1,1,0,0,0,0, DateTimeKind.Utc)).TotalMinutes;

Другие советы

You can use the DateTime.UtcNow function combined to a TimeSpan :

        DateTime reference = new DateTime(2001, 01, 01, 0, 0, 0, DateTimeKind.Utc);
        TimeSpan duration = new TimeSpan(DateTime.UtcNow.Ticks - reference.Ticks);
        ulong minutesCount = Convert.ToUInt64(duration.TotalMinutes);
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top