如何找到Laravel中两个时间戳之间的差异?

时间:2018-06-09 06:38:41

标签: php laravel datetime time

我正在尝试比较并找出两个时间戳之间的差异。所以,这就是我所做的。

    $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

所以,这种比较对我有用。但是,当我试图找到这两次之间的差异时,我得到一个错误说

"A non well formed numeric value encountered"

如何找到这两个时间戳之间的差异?

0 个答案:

没有答案