Last active
January 7, 2020 17:18
-
-
Save FauziFerdiansyah/1a74425b0e3c7e11cfe981ed9159687f to your computer and use it in GitHub Desktop.
Membuat helper tanggal Indonesia di laravel 5.* menggunakan CARBON
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
// reference time (%A, %e %B %Y %H:%M:%S) -> http://php.net/manual/en/function.strftime.php#refsect1-function.strftime-parameters