I need to be able to match a date format of this type:
Y-m-d\TH:i:s\+11:00
But instead of the +11:00, I would like it to be +XX:00 where XX can be any number.
I'm using
DateTime::createFromFormat('Y-m-d\TH:i:s\+11:00', $date);
And it throws an error if the +XX changes from 11.
You need escape characters in this way:
$date = '2017-08-20\T12:13:14\+11:00';
print_r( DateTime::createFromFormat('Y-m-d\\\\\TH:i:s\\\P', $date) );
$date = '2017-08-20T12:13:14+11:00';
print_r( DateTime::createFromFormat('Y-m-d\TH:i:sP', $date) );