[ Mini Kiebo ]
Server: Windows NT AKFAR_SERVER 10.0 build 26200 (Windows 10) AMD64
Path:
D:
/
xampp
/
htdocs
/
smk
/
application
/
libraries
/
[
Home
]
File: Tools.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Tools{ function indonesian_date ($timestamp = '', $date_format = 'l, j F Y | H:i', $suffix = 'WIB') { if (trim ($timestamp) == ''){ $timestamp = time (); }elseif (!ctype_digit ($timestamp)){ $timestamp = strtotime ($timestamp); } # remove S (st,nd,rd,th) there are no such things in indonesia :p $date_format = preg_replace ("/S/", "", $date_format); $pattern = array ( '/Mon[^day]/','/Tue[^sday]/','/Wed[^nesday]/','/Thu[^rsday]/', '/Fri[^day]/','/Sat[^urday]/','/Sun[^day]/','/Monday/','/Tuesday/', '/Wednesday/','/Thursday/','/Friday/','/Saturday/','/Sunday/', '/Jan[^uary]/','/Feb[^ruary]/','/Mar[^ch]/','/Apr[^il]/','/May/', '/Jun[^e]/','/Jul[^y]/','/Aug[^ust]/','/Sep[^tember]/','/Oct[^ober]/', '/Nov[^ember]/','/Dec[^ember]/','/January/','/February/','/March/', '/April/','/June/','/July/','/August/','/September/','/October/', '/November/','/December/', ); $replace = array ( 'Sen','Sel','Rab','Kam','Jum','Sab','Min', 'Senin','Selasa','Rabu','Kamis','Jumat','Sabtu','Minggu', 'Jan','Feb','Mar','Apr','Mei','Jun','Jul','Ags','Sep','Okt','Nov','Des', 'Januari','Februari','Maret','April','Juni','Juli','Agustus','Sepember', 'Oktober','November','Desember', ); $date = date ($date_format, $timestamp); $date = preg_replace ($pattern, $replace, $date); $date = "{$date} {$suffix}"; return $date; } function penyebut($nilai) { $nilai = abs($nilai); $huruf = array("", "satu", "dua", "tiga", "empat", "lima", "enam", "tujuh", "delapan", "sembilan", "sepuluh", "sebelas"); $temp = ""; if ($nilai < 12) { $temp = " ". $huruf[$nilai]; } else if ($nilai <20) { $temp = $this->penyebut($nilai - 10). " belas"; } else if ($nilai < 100) { $temp = $this->penyebut($nilai/10)." puluh". $this->penyebut($nilai % 10); } else if ($nilai < 200) { $temp = " seratus" . $this->penyebut($nilai - 100); } else if ($nilai < 1000) { $temp = $this->penyebut($nilai/100) . " ratus" . $this->penyebut($nilai % 100); } else if ($nilai < 2000) { $temp = " seribu" . $this->penyebut($nilai - 1000); } else if ($nilai < 1000000) { $temp = $this->penyebut($nilai/1000) . " ribu" . $this->penyebut($nilai % 1000); } else if ($nilai < 1000000000) { $temp = $this->penyebut($nilai/1000000) . " juta" . $this->penyebut($nilai % 1000000); } else if ($nilai < 1000000000000) { $temp = $this->penyebut($nilai/1000000000) . " milyar" . $this->penyebut(fmod($nilai,1000000000)); } else if ($nilai < 1000000000000000) { $temp = $this->penyebut($nilai/1000000000000) . " trilyun" . $this->penyebut(fmod($nilai,1000000000000)); } return $temp; } function terbilang($nilai) { if($nilai<0) { $hasil = "minus ". trim($this->penyebut($nilai)); } else { $hasil = trim($this->penyebut($nilai)); } return $hasil; } }