从资源创建中获取分钟的最佳方法是什么?

I need to pass to my view the time in minutes passed by an order submission. What is the best way to achieve that in Laravel and PHP? I've tried that but not working very well: $order->minutes = (new DateTime($order->created_at))->diff(new DateTime("now"))->format('%I');

I think in Laravel you can use Carbon for this.

$order->minutes = Carbon::now()->diffInMinutes($order->created_at);

The simplest way is like this (using Unix timestamps):

$submitted = '2018-10-11 10:00:00';

$diff = time() - strtotime($submitted);
//for minutes
if($diff > 0) $diff = floor($diff / 60);

echo $diff;