Skip to content

Instantly share code, notes, and snippets.

@ryzr
Last active April 3, 2020 02:11
Show Gist options
  • Save ryzr/6203299fadef949805ae to your computer and use it in GitHub Desktop.
Save ryzr/6203299fadef949805ae to your computer and use it in GitHub Desktop.
Fix null/empty -0001-11-30 00:00:00 dates
use Carbon\Carbon;
public function getCreatedAtAttribute($value)
{
//fixes 0000-00-00 00:00:00 date to return 1970-01-01 09:30:00 instead of -0001-11-30 00:00:00
return Carbon::createFromTimeStamp($value)->toDateTimeString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment