문제

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