I've been struggling for a few hours on an error that I'm sure it's silly, but I can't find to solve it.
My idea is to create a DateTime of (00:00:00), in order to add to it in a loop 4:30 hours per $i.
$saldo_funcionario = new DateTime('00:00:00');
for ($i=0; $i<$value; $i++) {
$tempo_dia_funcionario = new DateInterval('PT4H30I');
$saldo_funcionario->add($tempo_dia_funcionario);
}
The error message is:
Fatal error: Uncaught exception 'Exception' with message 'DateInterval::__construct(): Unknown or bad format (PT4H30I)'
DateInterval->__construct('PT4H30I') #1 {main} on line 75
Where am I missing?
Should be:
Notice 'M' instead of 'I'.
http://php.net/manual/en/dateinterval.construct.php