Skip to content
Advertisement

How To Use Gregorian Timestamp In Curl String

I’m trying to work with a curl request and the following string:

?created_from={FROM_TIMESTAMP}&created_to={TO_TIMESTAMP}

I’ve been working with the documentation quite a bit, so I know that brackets are not needed. Unfortunately, the only information I have is to us “Gregorian Timestamp” which I haven’t found a lot of documentation on.

I have tried a number of different combinations. Using timestamps for 10-01-2018 to 10-02-18. Here’s what I’ve tried:

?created_from=2019-02-01T00:00:00&created_to=2019-02-02T00:00:00)

This just returns logs from the past 30 days, not the specified date range.

Then I tried:

?created_from=1538352000&created_to=1538438400

This returns the following error message: "message":"created_to 63718254228 is more than 2682000 seconds from created_from 1538352000","cause":63718254228 which doesn’t make sense to me because the created_from is 1538352000 not 63718254228.

I have also tried a bunch of other syntax and combinations of formats like the following:

?created_from=2018-10-29T00:00:00Z&created_to=2018-11-01T00:00:00Z

And many other tries. Does anyone know how to properly write a Gregorian timestamp in a curl variable request? I’ve searched everywhere.

Advertisement

Answer

Gregorian timestamps have an epoch date of 0-01-01 00:00:00 as opposed to the standard UNIX epoch of 1970-01-01 00:00:00, which as a Gregorian timestamp is 62167219200.

So, you can simply add that to a UNIX timestamp to get the Gregorian value.

For example, consider the datetime 02/24/2019 @ 10:17pm (UTC), its UNIX timestamp is 1551046620. To obtain its Gregorian counterpart:

1551046620 + 62167219200 = 63718265820

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement