Search code examples
c#.netdatetimeepoch

Is there a generic representation of date using Epoch? Ticks vs milliseconds since Epoch


I am building an API that needs a date and I want to represent it using the Epoch.

Since I am developing in C# in .NET the ticks is an easy representation (100 nanoseconds). However, I need also to cater to implementors of the API in other programming languages.

Is the concept of Ticks used other than in C#? Should I go back to milliseconds since Epoch so the API is not designed too much with a .net flavor?

I know how to do the conversions, but I am looking for what makes more sense. My goal is to make the representation of dates easy for any programmer in all languages that may implement this API.


Solution

  • Whether you choose to use XML in your API or not, the standard defined in the XML Schema Part 2: Datatypes Second Edition is a pretty safe bet. See section 3.2.7, advising a specific version of one of the many ISO-8601 formats.