88class Helpers
99{
1010
11- //source from https://https://gist.github.com/matriphe/3103ec578ec556bad5047b378520f070
11+ public static function randomHexColor (){
12+ return '# ' . substr (str_shuffle ('ABCDEF0123456789 ' ), 0 , 6 );
13+ }
14+
15+ public static function filenameWithTimestamp ($ name , $ extention ){
16+ $ timestamp = time ();
17+ return $ timestamp . "_ " . $ name . ". " .$ extention ;
18+ }
19+
20+ public static function indonesianMonthName ($ date ) {
21+ $ tmp = date_format (new DateTime ($ date ),"n " );
22+ $ month = array (1 => 'Januari ' ,'Februari ' ,'Maret ' ,'April ' ,'Mei ' ,'Juni ' ,'Juli ' ,'Agustus ' ,'September ' ,'Oktober ' ,'November ' ,'Desember ' );
23+ return $ month [$ tmp ];
24+ }
25+
26+ public static function indonesianDayName ($ date ) {
27+ $ tmp = date_format (new DateTime ($ date ),"w " );
28+ $ day = array (1 => 'Senin ' ,'Selasa ' ,'Rabu ' ,'Kamis ' ,'Jumat ' ,'Sabtu ' ,'Minggu ' );
29+ return $ day [$ tmp ];
30+ }
31+
1232 public static function indonesianPoliceNumberformat ($ string )
1333 {
1434 $ string = strtoupper (trim ($ string ));
@@ -26,18 +46,20 @@ public static function indonesianPoliceNumberformat($string)
2646
2747 return null ;
2848 }
29-
49+
3050 public static function addDays ($ date , $ day ){
3151 return Carbon::createFromFormat ('Y-m-d ' ,$ date )->addDays ($ day )->toDateString ();
3252 }
33-
53+
3454 public static function indonesianFormatDecimal ($ number ){
35- $ temp = str_replace ('. ' ,'' ,$ number );
55+ $ temp = str_replace ('. ' ,'- ' ,$ number );
3656 $ temp = str_replace (', ' ,'. ' ,$ temp );
57+ $ temp = str_replace ('- ' ,', ' ,$ temp );
3758 return $ temp ;
3859 }
3960
40- public static function generatePassword ($ char ) {
61+ public static function generatePassword ($ char )
62+ {
4163 $ tmp = '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcefghijklmnopqrstuvwxyz ' ;
4264 return substr (str_shuffle ($ tmp ), 0 , $ char );
4365 }
@@ -60,8 +82,7 @@ public static function getAgeIndonesian($birthdate){
6082 $ day = $ diff ->d ;
6183 return $ year ." Tahun, " .$ month ." Bulan, " .$ day ." Hari " ;
6284 }
63-
64- public static function indonesianMonthName ($ date ) {
85+ public static function indonesianDate ($ date ) {
6586 $ date = date_create ($ date );
6687 $ month = date_format ($ date ,"n " );
6788 $ day = date_format ($ date ,"d " );
@@ -70,7 +91,7 @@ public static function indonesianMonthName($date) {
7091 return $ day .' ' .$ name [$ month ].' ' .$ year ;
7192 }
7293
73- public static function indonesianShortMonthName ($ date ) {
94+ public static function indonesianShortDate ($ date ) {
7495 $ date = date_create ($ date );
7596 $ month = date_format ($ date ,"n " );
7697 $ day = date_format ($ date ,"d " );
0 commit comments