Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

217
Views
Laravel - diffForHumans in German

I am trying to display the created_at attribute using Carbon's diffForHumans() in German in laravel 5.2.

created_at is stored in the database as: 2017-03-29 17:31:52

The model

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

public static function getCreatedAtAttribute($value)
{
    Carbon::setLocale('de');
    return Carbon::parse($value, 'Europe/Berlin')->diffForHumans();
}

dd($value); returns "2017-03-29 17:31:52".

The view

@foreach($posts as $post)
    <small>{{ $post->getCreatedAtAttribute($post->created_at) }}</small>
@endforeach

The error

DateTime::__construct(): Failed to parse time string (vor 3 Tagen) at position 0 (v): The timezone could not be found in the database


I would be very thankful for any kind of help!

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

For a German translation I used this customization in the AppServiceProvider:

class AppServiceProvider extends ServiceProvider
{
    public function boot()
    {
        // Localization Carbon

        \Carbon\Carbon::setLocale(config('app.locale'));
    }
}

With this setting the data is displayed: vor 3 Tagen instead of 3 days ago.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!