### Install Terbilang via Composer Source: https://github.com/riskihajar/terbilang/blob/2.x/README.md Use this command to add the Terbilang package to your Laravel project dependencies. ```bash composer require riskihajar/terbilang:^2.1 ``` -------------------------------- ### Publish Configuration Command Source: https://github.com/riskihajar/terbilang/blob/2.x/README.md Command to publish the package configuration file to the application. ```bash php artisan vendor:publish --provider="Riskihajar\Terbilang\TerbilangServiceProvider" ``` -------------------------------- ### Run project tests Source: https://github.com/riskihajar/terbilang/blob/2.x/README.md Execute the test suite using the Composer package manager. ```bash composer test ``` -------------------------------- ### Format Date and Time using Carbon Source: https://github.com/riskihajar/terbilang/blob/2.x/README.md Use Carbon instances directly for date and time conversion. ```php $dt = Carbon\Carbon::now('Asia/Makassar'); $date = Terbilang::date($dt); $time = Terbilang::time($dt); $datetime = Terbilang::datetime($dt); ``` -------------------------------- ### Default Configuration File Structure Source: https://github.com/riskihajar/terbilang/blob/2.x/README.md The default structure of the published configuration file for Terbilang. ```php return [ 'output' => [ 'date' => '{DAY} {MONTH} {YEAR}', 'time' => '{HOUR} {SEPARATOR} {MINUTE} {MINUTE_LABEL} {SECOND} {SECOND_LABEL}', ], 'locale' => 'en', 'distance' => [ 'type' => \Riskihajar\Terbilang\Enums\DistanceDate::Day, 'template' => '{YEAR} {MONTH} {DAY} {HOUR} {MINUTE} {SECOND}', 'hide_zero_value' => true, 'separator' => ' ', 'terbilang' => false, 'show' => [ 'year' => true, 'month' => true, 'day' => true, 'hour' => true, 'minute' => true, 'second' => true, ], ], ]; ``` -------------------------------- ### Register Service Provider and Facade Manually Source: https://github.com/riskihajar/terbilang/blob/2.x/README.md Manual registration for the service provider and facade in the Laravel configuration file. ```php // In the $providers array Riskihajar\Terbilang\TerbilangServiceProvider::class, // In the $aliases array 'Terbilang' => Riskihajar\Terbilang\Facades\Terbilang::class, ``` -------------------------------- ### Terbilang::make Source: https://github.com/riskihajar/terbilang/blob/2.x/README.md Converts a number into its word representation based on the configured locale. ```APIDOC ## Terbilang::make($number, $suffix, $prefix) ### Description Converts a numeric value into words. Supports optional prefix and suffix strings. ### Parameters - **$number** (mixed) - Required - The number to convert. - **$suffix** (string) - Optional - Text to append after the number. - **$prefix** (string) - Optional - Text to prepend before the number. ``` -------------------------------- ### Distance Date Configuration Source: https://github.com/riskihajar/terbilang/blob/2.x/README.md Configuration structure for distance date formatting. ```php 'distance' => [ 'type' => 'FULL', 'format' => '{YEAR} {MONTH} {DAY} {HOUR} {MINUTE} {SECOND}', 'hide_zero_value' => true, 'separator' => ' ', 'terbilang' => false, 'show' => [ 'year' => true, 'month' => true, 'day' => true, 'hour' => true, 'minute' => true, 'second' => true, ] ], ``` -------------------------------- ### Format Date and Time Source: https://github.com/riskihajar/terbilang/blob/2.x/README.md Convert date and time strings into word representations. ```php $date = date('Y-m-d'); // 2015-03-31 Terbilang::date($date); // Result : tiga puluh satu maret dua ribu lima belas ``` ```php $date = date('h:i:s'); //10:56:30 Terbilang::time($date); // Result : sepuluh lewat lima puluh enam menit tiga puluh tiga detik ``` ```php $date = date('Y-m-d h:i:s'); // 2015-03-31 10:58:27 Terbilang::datetime($date); // Result : tiga puluh satu maret dua ribu lima belas pukul sepuluh lewat lima puluh delapan menit dua puluh tujuh detik ``` -------------------------------- ### Terbilang::date, Terbilang::time, Terbilang::datetime Source: https://github.com/riskihajar/terbilang/blob/2.x/README.md Converts date and time strings into their word representations. ```APIDOC ## Terbilang::date($date, $format='Y-m-d') ## Terbilang::time($date, $format='h:i:s') ## Terbilang::datetime($date, $format='Y-m-d h:i:s') ### Description Converts date or time strings into words. Can accept Carbon instances or date strings. ### Parameters - **$date** (mixed) - Required - The date or time string/object. - **$format** (string) - Optional - The format of the input string. ``` -------------------------------- ### Add Prefix and Suffix to Number Conversion Source: https://github.com/riskihajar/terbilang/blob/2.x/README.md Include custom prefixes and suffixes when converting numbers to words. ```php Terbilang::make(123456, ' rupiah', 'senilai '); // senilai seratus dua puluh tiga ribu, empat ratus lima puluh enam rupiah ``` ```php Terbilang::make(654321, ' dollars'); // six hundred and fifty-four thousand, three hundred and twenty-one dollars ``` -------------------------------- ### Convert Number to Words by Locale Source: https://github.com/riskihajar/terbilang/blob/2.x/README.md Convert numbers to words using different locales. ```php Config::set('terbilang.locale', 'en'); Terbilang::make(1000000); // one million ``` ```php Config::set('terbilang.locale', 'id'); Terbilang::make(1000000); // satu juta ``` -------------------------------- ### Convert Large Numbers to Short Format Source: https://github.com/riskihajar/terbilang/blob/2.x/README.md Convert large numbers into shorthand formats like kilo, million, billion, or trillion. ```php Terbilang::short(1000000); // 1M ``` ```php Terbilang::short(1000000); // 1jt ``` -------------------------------- ### Convert Number to Roman Numerals Source: https://github.com/riskihajar/terbilang/blob/2.x/README.md Convert an integer to its Roman numeral representation. ```php Terbilang::roman(1234); // MCCXXXIV ``` -------------------------------- ### Terbilang::short Source: https://github.com/riskihajar/terbilang/blob/2.x/README.md Converts a large number into a shorthand format (kilo, million, billion, trillion). ```APIDOC ## Terbilang::short($number, $format) ### Description Formats large numbers into shorthand strings like '1M' or '1jt' depending on the locale. ### Parameters - **$number** (mixed) - Required - The number to format. - **$format** (string) - Optional - The shorthand unit (kilo, million, billion, trillion). ``` -------------------------------- ### Terbilang::period Source: https://github.com/riskihajar/terbilang/blob/2.x/README.md Calculates the difference between two dates and returns the result in words. ```APIDOC ## Terbilang::period($start, $end=null, $format=null) ### Description Calculates the duration between two dates or between a date and the current time. ### Parameters - **$start** (string) - Required - The start date. - **$end** (string) - Optional - The end date. - **$format** (string) - Optional - Custom format string. ``` -------------------------------- ### Calculate Date Distance Source: https://github.com/riskihajar/terbilang/blob/2.x/README.md Calculate the difference between two dates or a date and the current time. ```php $date1 = date('Y-m-d', strtotime('2017-05-01')); // dateformat must Y-m-d H:i:s $date2 = date('Y-m-d', strtotime('2017-06-15 09:30:15')); // this method will diff $date1 with current datetime value for example current datetime : 2017-09-08 15:17:54 Terbilang::period($date1); // Result : 4 months 8 days 15 hours 17 minutes 54 seconds Terbilang::period($date1, $date2); // Result : 1 months 15 days 9 hours 30 minutes 15 seconds // if you set locale to id Terbilang::period($date1, $date2); // Result : 1 bulan 15 hari 9 jam 30 menit 15 detik // if you set config period.terbilang to true Terbilang::period($date1, $date2); // Result : satu bulan lima belas hari sembilan jam tiga puluh menit lima belas detik // if you set config period.type to DAY Terbilang::period($date1, $date2); // Result : 45 hari ``` -------------------------------- ### Terbilang::roman Source: https://github.com/riskihajar/terbilang/blob/2.x/README.md Converts a number into a Roman numeral string. ```APIDOC ## Terbilang::roman($number, $lowercase=false) ### Description Converts an integer into a Roman numeral representation. ### Parameters - **$number** (int) - Required - The number to convert. - **$lowercase** (bool) - Optional - Whether to return the result in lowercase. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.