Datetime with unknown parameters

Asked

Viewed 79 times

1

I am integrating a program with Contaazul and one of the parameters is the date. Their date format is this: "2020-01-08T16:28:59.966Z"

To get in PHP this date some parts is quiet, however someone knows what is this "T" and this ". 966Z" after hours? What date and time format is this?

What are these values and how to get them through PHP? I couldn’t find anything in their documentation.

  • 1

    The date format is in the American standard, where ANO/MÊS/DIA or yyyy/mm/dd. The T means TEAM (Time). the .966 would be the milliseconds

  • It worked Jakson. Thank you!

  • Come on, you’re welcome, my friend :)

  • Jakson, the API returned: yyyy-MM-dd’T'HH:mm:ss.SSSX, this SSSX is the milliseconds?

  • 1

    Can you give me the documentation link so I can take a look?

  • 2

    @Jaksonfischer Actually the American format is "month/day/year". This question format is defined by ISO 8601 standard, and is "year-month-day" (hyphenated instead of bars).

  • 1

    @hkotsubo, in fact, confused me at the time of information

Show 2 more comments

1 answer

2


This format is defined by ISO 8601 standard. According to this standard, the capital letter "T" is used to separate date and time fields. So we have "year-month-day," followed by the letter "T," followed by "hour:minute:second".

The seconds can have the fractions (using the point as the decimal separator), which in their case are 966 milliseconds.

"Z" indicates this date and time is in UTC.

In PHP you can use a DateTime, that already recognizes this format by default:

$d = new DateTime('2020-01-08T16:28:59.966Z');

// mostrar a data em outro formato
echo $d->format('d/m/Y H:i:s.u e'); // 08/01/2020 16:28:59.966000 Z

As to the your comment on the format be "yyyy-MM-dd’T'HH:mm:ss.SSSX", probably "X" refers to the offset, which is the difference with UTC. In its example, the "Z" refers to UTC itself, which is the same as saying that the offset is zero. You can see more information about offsets in wiki of the tag Timezone.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.