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

209
Views
Laravel - diffForHumans en alemán

Estoy tratando de mostrar el atributo created_at usando diffForHumans() de Carbon en alemán en laravel 5.2.

created_at se almacena en la base de datos como: 2017-03-29 17:31:52

El modelo

 protected $dates = ['created_at', 'updated_at']; public static function getCreatedAtAttribute($value) { Carbon::setLocale('de'); return Carbon::parse($value, 'Europe/Berlin')->diffForHumans(); }

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

La vista

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

El error

DateTime::__construct (): no se pudo analizar la cadena de tiempo (vor 3 Tagen) en la posición 0 (v): la zona horaria no se pudo encontrar en la base de datos


Estaría muy agradecido por cualquier tipo de ayuda!

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Para una traducción al alemán, utilicé esta personalización en AppServiceProvider:

 class AppServiceProvider extends ServiceProvider { public function boot() { // Localization Carbon \Carbon\Carbon::setLocale(config('app.locale')); } }

Con esta configuración se muestran los datos: vor 3 Tagen en lugar de 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!