That is the correct format since a while back, so you need to cast it.
https://laravel.com/docs/10.x/eloquent-mutators#date-casting
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi, I am hosting Laravel 10 project on Ubuntu server. It has a report. But current time in database is not given correctly in ubuntu server. Help me to get correct time format in ubuntu server.
Database created_at :2023-07-31 08:18:19 Ubuntu server report view :"2023-07-31T02:48:19.000000Z"
Product Controller :
public function report(Request $request) { $searchOptions = $request->get('search', null); $searchKeyword = $searchOptions['value'] ?? null;
$FromDate = $request->get('from_date', null);
$ToDate = $request->get('to_date', null);
$query = Product::query()
->leftJoin('users', 'users.id', '=', 'products.user_id')
->selectRaw('products.*, users.name')
->when((!is_null($FromDate) && !is_null($ToDate)), function ($q) use ($FromDate, $ToDate) {
$ToDate = Carbon::parse($ToDate)->addDays(1);
$q->whereBetween('products.created_at', [$FromDate, $ToDate]);
})
->when($searchKeyword !== '', function ($q) use ($searchKeyword) {
$q->where('users.name', 'LIKE', '%'.$searchKeyword.'%')
->orWhere('products.workorder', $searchKeyword);
});
$total = $query->count();
$product = $query->simplePaginate($total);
if ($request->expectsJson()) {
return response()->json($product);
}
return view('products.report', compact('product'));
}
How to fix it??????????????
Please or to participate in this conversation.