Skip to content

Instantly share code, notes, and snippets.

@ricardobarantini
Last active October 11, 2017 17:53
Show Gist options
  • Save ricardobarantini/68befd87dee76ffffc0b77590c1b9355 to your computer and use it in GitHub Desktop.
Save ricardobarantini/68befd87dee76ffffc0b77590c1b9355 to your computer and use it in GitHub Desktop.
Modifica o formato da data usando Carbon no Laravel
<?php
public function setDataAttribute($value)
{
$this->attributes['data'] = Carbon::createFromFormat('d/m/Y', $value)->toDateString();
}
public function getDataAttribute($value)
{
return Carbon::parse($value)->format('d/m/Y');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment