Skip to content

Instantly share code, notes, and snippets.

@olssonm
Created October 30, 2020 08:39
Show Gist options
  • Save olssonm/ac8ef0cb9b8492542365df40ecfb5c6f to your computer and use it in GitHub Desktop.
Save olssonm/ac8ef0cb9b8492542365df40ecfb5c6f to your computer and use it in GitHub Desktop.
Set localized time via Carbon in Laravel
<?php
public function register()
{
// Prefered method
\Carbon\Carbon::setUTF8(true);
\Carbon\Carbon::setLocale(config('app.locale'));
setlocale(LC_TIME, config('app.locale'));
// If a specific language-pack is installed/to be used
\Carbon\Carbon::setUTF8(true);
\Carbon\Carbon::setLocale(config('app.locale'));
setlocale(LC_TIME, 'sv_SE.utf8'); // Language pack "sv_SE.utf8"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment