I'm currently using ConstantContact which returns XML with updated field in format like this:
2013-02-13T08:35:34.195Z
I'm assuming this is date('c') format. How to parse this format? strtotime isn't returning correct value.
You may want to take a look at the DateTime::createFromFormat() function.
$datetime = DateTime::createFromFormat('Y-m-d\TH:i:s+', '2013-02-13T08:35:34.195Z');
The problem with that is you're going to loose the milliseconds.
The +
sign in the format string simply tells this function to ignore the rest of the string instead of creating an error.
Confirmed in PHP7.2. As in comment below you can use Y-m-d\TH:i:s.u\Z
to match the exact Js string that toISOString gives.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With