如何将日期格式从Y-m-d转换为d-m-Y?

I'm trying to convert the date_of_birth column's date format from Y-m-d to d-m-Y.
Below is my model:

use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Auth;

class Stock extends Model
{
    protected $primaryKey = 'tag_no';    
    public $incrementing = false;    
    protected $fillable = [        
        'tag_no',
        'stock_type',        
        'date_of_birth',                  
    ];

    protected $dates=[
        'created_at',
        'updated_at',
        'deleted_at',
        'date_of_birth'
    ];


    public function getDateOfBirthAttribute($value)
    {
        return Carbon::parse($value)->format('Y-m-d');
    }

    public function setDateOfBirthAttribute($value)
    {
        $this->attributes['date_of_birth'] = date('d-m-Y', strtotime($value));
    }
}

Is this the right way?

    $in = '2018-08-20';
    $out = \DateTime::createFromFormat('Y-m-d', $in)->format('d-m-Y');
    print_r($out); // 20-08-2018