0
I have the following code:
<?php
//batidas do controle de ponto de um x colaborador
$d1 = new DateTime('2021-08-06 12:00:00');
$d2 = new DateTime('2021-08-06 15:00:00');
$d3 = new DateTime('2021-08-06 15:30:00');
$d4 = new DateTime('2021-08-06 17:00:00');
$d5 = new DateTime('2021-08-06 17:30:00');
$d6 = new DateTime('2021-08-06 21:00:00');
$i1 = $d1->diff($d2);
$i2 = $d2->diff($d3);
$remover = new DateInterval("T1H");
echo $i1->format('%H:%I') . "<br />";
echo $i2->format('%H:%I') . "<br />";
print_r($i1->sub($remover));
Then you make the following mistake:
"FATAL ERROR Uncaught Exception: Dateinterval::__Construct(): Unknown or bad format (T1H) in /var/www/html/index.php74(3) : Eval()’d code:13 Stack trace: #0 /var/www/html/index.php74(3) : Eval()’d code(13): Dateinterval->__Construct('T1H') #1 /var/www/html/index.php74(3): Eval() #2 {main} thrown on line number 13"
But I don’t know what’s wrong? I would like to subtract an hour from the variable $i1
or put as parameter in the class DateInterval()
an hour with seconds or not dynamically?