Use Laravels Lang system.
http://laravel.com/docs/master/localization
Date Format depends on language?
Hello Guys, i have a question to date formats in different languages.
In my Model i want to have a function like that:
public function created_at()
{
return new DateHelper->format(new GermanFormat($this->created_at));
}
ok cool. But now i want to add "English" language to my app. So i created a new EnglishFormat class.
But now it sucks...
My Model function have to be like that:
public function created_at()
{
// if DE THEN
return new DateHelper->format(new GermanFormat($this->created_at));
// if EN then
//return new DateHelper->format(new EnglishFormat($this->created_at));
}
Do you have a better idea for me? I dont like the IF statements...
In terms of localising the dates and any text within the date display, I make use of this package https://github.com/jenssegers/date which extends from Carbon.
For the format of the date itself, doing what Zach suggested could work very well. Just a single item called format, then just grab it in your model using the trans function.
Please or to participate in this conversation.