简体   繁体   中英

Does DateTime.UtcNow.Ticks in .NET match any standard?

Investigating the data sent/received via an web API. I found that in some places they are sending/receiving the long value of DateTime.UtcNow.Ticks . It is used to describe a specific point in time (eg in the meaning of valid until).

The docs explain what they are but I am actually wondering if this matches any standard? It's definitly not unix epoch or something in my opinion. So how would you describe it for a client that consumes the API but is not developed in C#?

Ticks in C# are very well defined:

... represents the number of 100-nanosecond intervals that have elapsed since 12:00:00 midnight, January 1, 0001 in the Gregorian calendar. https://docs.microsoft.com/en-us/dotnet/api/system.datetime.ticks?view=net-5.0

Unless you need 100-nanosecond accuracy (which is unlikely), I suggest you start using ISO8601 , which looks something like YYYY-MM-DDThh:mm:ss.fffZ, and is very well supported in most languages.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM