Skip to content

Instantly share code, notes, and snippets.

@FauziFerdiansyah
Last active January 7, 2020 17:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FauziFerdiansyah/1a74425b0e3c7e11cfe981ed9159687f to your computer and use it in GitHub Desktop.
Save FauziFerdiansyah/1a74425b0e3c7e11cfe981ed9159687f to your computer and use it in GitHub Desktop.
Membuat helper tanggal Indonesia di laravel 5.* menggunakan CARBON
// ini diletakan di HELPER atau langsung di controllernya
public static function keIndonesia($tgl) {
$dt = new \Carbon\Carbon($tgl);
setlocale(LC_TIME, 'IND');
return $dt->formatLocalized('%A, %e %B %Y'); // Senin, 3 September 2018
}
public static function keIndonesia_w_time($tgl) {
$dt = new \Carbon\Carbon($tgl);
setlocale(LC_TIME, 'IND');
return $dt->formatLocalized('%A, %e %B %Y %H:%M:%S'); // Senin, 3 September 2018 00:00:00
}
// reference time (%A, %e %B %Y %H:%M:%S) -> http://php.net/manual/en/function.strftime.php#refsect1-function.strftime-parameters
@FauziFerdiansyah
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment