laravel model created_at format edit
{{ date('d.m.Y H:i:s', strtotime($value->created_at)) }}
laravel model created_at format edit
{{ date('d.m.Y H:i:s', strtotime($value->created_at)) }}
laravel model created_at format edit
//In your Post model add two accessor methods like this:
public function getCreatedAtAttribute($date)
{
return Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $date)->format('Y-m-d');
}
public function getUpdatedAtAttribute($date)
{
return Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $date)->format('Y-m-d');
}
//Now every time you use these properties from your model to show a date these will be presented differently, just the date without the time, for example:
$post = Post::find(1);
echo $post->created_at; // only Y-m-d formatted date will be displayed
//So you don't need to change the original type in the database. to change the type in your database you need to change it to Date from Timestamp and you need to do it from your migration (If your using at all) or directly into your database if you are not using migration. The timestamps() method adds these fields (using Migration) and to change these fields during the migration you need to remove the timestamps() method and use date() instead, for example:
$table->date('created_at');
$table->date('updated_at');
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us