dongyinglan8707 2018-08-10 18:41
浏览 684
已采纳

“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?

  • 写回答

1条回答 默认 最新

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 如何抓这个函数的包wx.updateShareMenu
      • ¥15 需要数据分析!时间紧!
      • ¥15 关于免费论文查重系统的问题。
      • ¥15 朋友们,这个sim函数是出了什么问题了呢
      • ¥15 【MRT数据导入问题】MRT处理modis数据提示opening input header file怎么解决?
      • ¥15 嵌入式系统综合设计题有会的教一下嘛?
      • ¥15 yolov5转onnx验证出错
      • ¥15 proteus仿真LCD不点亮
      • ¥15 C语言红绿灯时间问题
      • ¥15 matlab仿真实现定位算法