I am doing a test, with an Oracle database query (writing sysdate, result: 13/09/2016 13:24:44) and returning me in PHP. I need to calculate the difference in hours and I was trying the function below:
$date_a = new DateTime($p_fim[$passo]);
$date_b = new DateTime($p_inicio[$passo]);
$interval = date_diff($date_a,$date_b);
echo $interval->format('%h:%i:%s');
But you are returning the error below:
Fatal error: Uncaught exception 'Exception' with message 'DateTime :: __ construct (): Failed to parse time string (9/13/2016 13:24:44) at position 0 (1): Unexpected character '
Browsing the same OS all use the 2016-09-13 format. That's right? Do I need to convert before passing the value?