Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

cooperino's avatar

Changing date format on fetched Eloquent model

If I have a query to fetch a model like so:

model = $model::where('user_id', Auth::id());

Is it possible to change the format if specific columns that represent date?

0 likes
5 replies
cooperino's avatar

@EricZwart is there a way to show "UTC" or "GMT" instead of the letter "Z" when I use format with "T"?

ehab.aboshehab's avatar

@sanchezw if it is timestamp the you can do something like

$user->created_at->format('Ymd');

if normal datetime type you can parse it using carbon :

use Carbon\Carbon;

$dateFormat = Carbon::parse($user->some_date)->format();

Please or to participate in this conversation.