UTC time in ticks (from 01/01/0001 00:00:00)

I'm trying to integrate with a third-party service that wants to know how much "UTC time in ticks (from 01/01/0001 00:00:00)" has passed.

What is a checkmark?

Assuming this is the second (and I don't know what it is) ... how should I do this from 01/01/0001 00:00:00? It is more than a 32-bit integer. Not sure if this is more than a 64-bit integer, but PHP date () functions return 32-bit integers, not 64-bit ones.

If I knew how many seconds elapsed between 01/01/0001 00:00:00 and the UNIX era, I could use bcmath or gmp to add this amount (as a constant) during () (again, if the ticks are - seconds), but I do not know what this number is.

Any ideas?

+4
source share
3 answers

I expect the service is written in .NET since the .NET framework knows DateTime.Ticks. the documentation says about tick:

One tick represents one hundred nanoseconds or one tenth of a millionth of a second. In milliseconds, there are 10,000 ticks.

The value of this property is the number of 100 nanosecond intervals elapsed from 12:00 to midnight, January 1, 0001, which represents DateTime.MinValue. It does not include the number of ticks that relate to leap seconds.

Thus, you will have a few seconds from 01/01/0001 00:00:00 to 10.000.000.

I found the value:

621,355,968,000,000,000 

for ticks from 01-01-0001T00: 00: 00 to 01-01-1970 in this message fooobar.com/questions/1457826 / .... I do not know how it was calculated. I assume the .NET framework will output it. I would suggest checking the value and declaring it as a constant in PHP, as you mentioned.

PHP int type is a signed integer. Its size depends on the system you are using. If its a 64-bit system, the range of values ​​should be large enough for this purpose. If not, you can use the GMP extension or the BC Math extension to work with large numbers.

+3
source

There is no standard definition for ticks. It can mean seconds, 50s, 60s, or 100s, milliseconds, or any number of other units. Contact your service provider for details.

If they want you to count from the 1st year, this raises all sorts of other unpleasant questions, because the Gregorian calendar (the one that we use today) was not introduced until 1582! (The UTC standard was not standardized until 1961.) A service provider may or may not consider calendar changes.

One easy way to check all of this would be to ask them what the value is right now (or some other last reference date).

+1
source

Unix time is the seconds elapsed since January 1, 1970. Of course, you can use a special library like bcmath to add a timestamp. Unix time is 1970 years later than UTC, so the constant will be 70 * 365 * 24 * 60 * 60 seconds.

-2
source

All Articles