How to format timestamp in laravel?

Advertisements

I have this timestamp created_at

public function getCreatedAtAttribute($value)
{
    return Carbon::parse($value)->format('M d, Y h:i:s');
}

How can I format this like Oct 9, 2021 at 1:23 PM with an at string?

>Solution :

You can add the string by escaping the characters:

return Carbon::parse($value)->format('M d, Y \a\t H:i');

Leave a ReplyCancel reply