Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function dateToIndo($date,$short=false){
- $BulanIndo = array("Januari", "Februari", "Maret","April", "Mei", "Juni","Juli", "Agustus", "September","Oktober", "November", "Desember");
- $bln_short = array("Jan","Feb","Mar","Apr","Mei","Jun","Jul","Agust","Sep","Okt","Nop","Des");
- $tahun = substr($date, 0, 4);
- $bulan = substr($date, 5, 2);
- $tgl = substr($date, 8, 2);
- $jam = substr($date, 11, 8);
- if(!$short){
- $result = $tgl . " " . $BulanIndo[(int)$bulan-1] . " ". $tahun." ".$jam;
- }else{
- $result = $tgl . " " . $bln_short[(int)$bulan-1] . " ". $tahun." ".$jam;
- }
- return($result);
- }
- //Contoh penggunaan
- $date = date("Y-m-d"); //2016-02-26
- echo dateToIndo($date); // hasilnya adalah 26 Februari 2016
- echo dateToIndo($date,true); // hasilnya adalah 26 Feb 2016
- ?>
Advertisement
Add Comment
Please, Sign In to add comment