I have use PHP to convert a simple datetime from MySQL
example: 2022-02-21 10:26:27
to a format like this one:
2021-08-17T10:19:02.019Z
.
What function and formatting pattern should I use?
Also, could you please help me understand what the .019Z
stand for?
Thank you!
EDIT:
Using echo date("c");
results in an output like this one: 2022-02-21T14:14:22+01:00
, which differs form the desired output in the latest part (milliseconds and timezone).
On the other hand, if I do echo date("Y-m-d\TH:i:s.v");
I get an output like the following: 2022-02-21T14:22:24.000
, where I should only be missing the timezone. I am not able to find it in the documentation.
The server isn't on the standard timezone, and I would like not to change it. Is there a way to get it dynamically?