dongzz4545 2018-06-09 06:38
浏览 34

如何找到Laravel中两个时间戳的区别?

I am trying to compare and find difference between two timestamps. So, this is what I have done.

    $add_time = config('constant.time'); //Adding 5 minutes
    $time = date("Y-m-d H:i:s", strtotime($approval->updated_at . '+'.$add_time.' minutes')); //2018-06-09 06:11:13

    $now  = date("Y-m-d H:i:s"); // //2018-06-09 06:42:27


    if($now > $time)
    {
     print_r("Time working")
    }else {
           print_r("Not Working")
          }

    $diff = $now - $time; //Throws Error

So, this comparison is working for me. But, when I try to find the difference between these two times, I get an error saying

"A non well formed numeric value encountered"

How can I find the difference between these two timestamps?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
    • ¥15 正弦信号发生器串并联电路电阻无法保持同步怎么办
    • ¥15 划分vlan后,链路不通了?
    • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
    • ¥15 Vue3 大型图片数据拖动排序
    • ¥15 Centos / PETGEM
    • ¥15 划分vlan后不通了
    • ¥20 用雷电模拟器安装百达屋apk一直闪退
    • ¥15 算能科技20240506咨询(拒绝大模型回答)
    • ¥15 自适应 AR 模型 参数估计Matlab程序