“DateTime :: __ construct():无法解析时间字符串(@)”函数中的致命错误

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?

You are calling your function without passing in any amount of seconds. new DateTime("@") is indeed an error, as the UNIX Timestamp format requires at least one digit.

Consider adding the typehint function secondsToTime(int $seconds) as this will ensure you actually have a number.