4
I have this simple file:
php test.
<?php
$date1='2018-01-09 16:14:01';
$date2='2018-01-09 17:30:04';
$dateS1 = new \DateTime($date1);
$dateS2 = new \DateTime($date2);
$dateDiff = $dateS1->diff($dateS2);
$result = $dateDiff->h . ' horas e ' . $dateDiff->i . ' minutos';
echo $result;
?>
In theory I should return the difference in hours and minutes, but I turn only a blank page.
Do you think it might be the PHP version on my machine? I use version 5.1.6
this code is right, has been tested and works normally, if you can post the error that appears,
– Julio Henrique
That’s the problem kkk, returns nothing, just a blank page
– Geraldão de Rívia
Here it worked perfectly. Are the two files in the same folder? the file funcoes.php has the <?php and <?php tags ?>?
– Rafael Weber
You could pass all the content of.php functions?
– Rafael Weber
@Rafaelweber, yes all the files are in a single folder, and tb are with the tags, I will edit the question with the code in a single file to facilitate, because try together and tb did not work
– Geraldão de Rívia
no errors, see http://kithomepage.com/sos/paginainclud.php
– user60252
According to the PHP Documentation the version must be greater than or equal to 5.3 http://php.net/manual/en/datetime.diff.php
– Rafael Weber
@Rafaelweber, puts, so this is it :(, I’m on the company server, there’s another way to make this difference calculation?
– Geraldão de Rívia
I ran this code in version 5.1.6 of php and it gave fatal error, date time class not found
– Julio Henrique
Test on this site, you have all versions of php to test, this is version 5.3 http://sandbox.onlinephpfunctions.com/code/6e4b72504cc1454f009e4acaf17c912ace3ded25
– user60252
And this is version 5.1.6 http://sandbox.onlinephpfunctions.com/code/8a71b4c79f70e95507984388c01624e563a52c70
– user60252