I’m trying to integrate with a third party service that wants to know how many “UTC time in ticks (since 01/01/0001 00:00:00)” have passed.
What is a tick?
Assuming it’s a second (and I don’t know that it is)… how am I supposed to do it since 01/01/0001 00:00:00? That’s bigger than a 32-bit integer. Not sure if it’s bigger than a 64-bit integer but PHP’s date() functions return 32-bit integers – not 64-bit ones.
If I knew how many seconds had elapsed between 01/01/0001 00:00:00 and UNIX epoch I could use bcmath or gmp to add that amount (as a constant) to time() (again assuming ticks are seconds) but I don’t know what that number would be.
Any ideas?
I expect the service written in .NET as the .NET framework knows DateTime.Ticks. The documentation says about a tick:
So you’ll have to multiple seconds since 01/01/0001 00:00:00 by 10.000.000.
I found the value:
for the ticks from 01-01-0001T00:00:00 until 01-01-1970 in this SO post. I don’t know how it has been calculated. I assume the .NET framework will output it. I would suggest to verify the value and declare it as a constant in PHP as you mentioned.
PHP’s int type is a signed integer. Its size depends on the system you are using. If its a 64bit system the value range should be large enough for the purpose. If not you can use the GMP extension or the BC Math extension for working woth large numbers.