This question already has an answer here:
I need to convert a datetime string format (2019-04-08 09:39:23) to this format : 2019-04-08T16:14:44.000Z - this is just an example output - I don't know what the actual value is in T-Z.
$t = "20190408093923"; # 2019-04-08 09:39:23
echo date("Y-m-dTH:i:sZ", strtotime($t));
echo PHP_EOL;
</div>
You need to escape any letters that aren't formatting specifications.
echo date("Y-m-d\TH:i:s\Z", strtotime($t));