I have a dhEmi tag that has this value 2016-09-09T08:10:52-03:00
To return a datetime I did the following.
$dtemis = $item->infNFe->ide->dhEmi;
$res = explode("T", $dtemis);
$res1 = explode("-03:00", $res[1]);
$array = array ($res[0],$res1[0]);
$dtemisformat = implode (' ', $array);
$dtemisformat = ''.$dtemisformat.'.000';
The code above returns me 2016-09-09 08:10:52.000
but the -03: 00 value in the $res1 = explode("-03:00", $res[1]);
line is not always the same for example: -02: 00 .
Are there any suggestions for improving the code?