Search code examples
phpdatetimeunix-timestamp

PHP Date and Time Format for an API request to Linnworks


IN the Linnworks API documentation and Start and End Date is required for one of the API requests. The format for this is as follows;

 2018-02-19T16:57:07.0049771+00:00

I am unsure on this formatting. Is this a default formatting of some sort or would I need to construct it?

If I need to construct, I get the obvious portions;

Date;

2018-02-19

Time;

T16:57:07

But what this portion is I do not know;

0049771+00:00

Is it the Unix Time Stamp and a + for time zone?


Solution

  • This is ISO8601 format, which states:

    Decimal fractions may be added to any of the three time elements. However, a fraction may only be added to the lowest order time element in the representation.

    Considering the use of the word "may" here, I would expect that the API should allow you to specify the timestamp without any such decimal portion, assuming that is acceptable for your application. (Disclaimer -- this is a guess.)

    If so, this can be had simply via:

    echo date('c');
    

    Which yields:

    2018-03-20T16:24:37-04:00