This works for me
$user->created_at->format('d M Y - H:i:s');
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello I have some glitches with date formating in latest laravel version. I used laravel migration timestamps() for table, date works fine until i try to add ->format() to created_at column, whenever i try it just respond with this error: Fatal error: Call to a member function format() on string, I have no clue why it doesn't work, on updated_at column it works fine, but on created_at it don't.
And second mail queueing, I tried events and jobs for it, but it always works as just plain sending making my request longer, I just wan't to make that whenever someone registers then mail is being sent after he did register request. Not when he pressed registration button.
In job file handle code:
public function handle(Mailer $mailer)
{
$user = $this->user;
$mailer->queue('emails.user-confirmation', ['user' => $user], function($mail) use ($user) {
$mail->to($user->email);
$mail->subject('Account confirmation');
});
}
Seems like migration with removing and adding those columns back again fixed this problem, no clue why it wasn't working at first, but now its working. Thanks for help.
Please or to participate in this conversation.