<?php protected $casts = [ 'published_at' => 'datetime' ];
<?php $post = Post::first()->published_at; dd($post->format('d M y')); // 26 Jun 21 dd($post->diffForHumans()); // 1 day ago
Learn how to cast datetime column to Carbon instance to get all of the helpful method in Laravel
Created on Aug 19, 2021
•3361 views
<?php protected $casts = [ 'published_at' => 'datetime' ];
<?php $post = Post::first()->published_at; dd($post->format('d M y')); // 26 Jun 21 dd($post->diffForHumans()); // 1 day ago
If you like our tutorial, do make sure to support us by being our Patreon or buy us some coffee ☕️
Load comments for How to cast datetime column to Carbon instance in Laravel
Collection of Tailwind CSS components for everyone to use. Browse all of the components that are right for your project.
View Components2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
1 year ago