I turn time into time with function but I'm getting an error that I do not fully understand.
Function:
function secondsToTime($seconds)
{
$dtF = new DateTime("@0");
$dtT = new DateTime("@$seconds");
return $dtF->diff($dtT)->format('%a Days, %h H %i M');
// return $dtF->diff($dtT)->format('%a days, %h hours, %i minutes and %s seconds');
}
Error:
PHP Fatal error: Uncaught Exception: DateTime::__construct(): Failed
to parse time string (@) at position 0 (@): Unexpected character in
/home/user/public_html/Config.php:479 Stack
trace:
#0 /home/user/public_html/Config.php(479): DateTime->__construct('@')
#1 /home/user/public_html/index.php(56):
secondsToTime('')
#2 {main} thrown in /home/user/public_html/Config.php on line 479
what could be the cause of this error?