Advertisement

Responsive Advertisement

Mengubah Tanggal Menjadi Indonesia dengan Carbon di Laravel

 




  1. See if the locale is installed in your server.

    You can list all the locale in your server by issuing the command

    locale -a

  2. Install your locale. Indonesian locale, I believe is id_ID by issuing the command. The list of locale is obtained from this answer https://stackoverflow.com/a/28357857/5808894

    sudo locale-gen id_ID

    sudo update-locale

  3. Set locale using the method setlocale

    setlocale(LC_TIME, 'id_ID');

  4. Either use Carbon or strftime to output the localized date

    strftime("%a %d %b %Y", strtotime(date('Y-m-d')))

    OR

    Carbon\Carbon::parse('23-03-2017 11:23:45')->formatLocalized('%A %d %B %Y');

    outputs Kamis 23 Maret 2017



Referensi lengkap Medium

Posting Komentar

0 Komentar