jump to navigation

Lokal Date March 2, 2006

Posted by ar10 in PHP & MySQL.
trackback

Kalau kamu punya web dengan bahasa program PHP,kamu bisa menampilkan tanggal dengan bahasa yang kamu inginkan, bisa pakai bahasa indonesia, jawa, banyumas, dll. Salah satu script untuk menampilkan tanggal dalam bahasa lokal ya ini:

week_day = date(“l”);
$this->day = date(“j”);
$this->month = date(“n”);
$this->year = date(“Y”);
}
//translasi ke bahasa lokal
function get_day() {
$nl_day = array(“Monday” => “Senin”, “Tuesday” => “Selasa”, “Wednesday” => “Rabu”, “Thursday” => “Kamis”, “Friday” => “Jumat”, “Saturday” => “Sabtu”, “Sunday” => “Minggu”);
return $nl_day[$this->week_day];
}
function get_month() {
$nl_month = array(“1” => “Januari”, “Februari”, “Maret”, “April”, “Mei”, “Juni”, “Juli”, “Agustus”, “September”, “Oktober”, “November”, “Desember”);
return $nl_month[$this->month];
}
function build_date() {
$long_date = $this->day.” “.$this->get_month().” “.$this->year;
return $long_date;
}
}
// penggunaan
$my_date = new local_date;
$tgl=$my_date->get_day().”,”.$my_date->build_date();
echo ” $tgl”;
?>

Kamu bisa mengubah sendiri format bahasa untuk nama hari dan bulan. Coba aja sendiri klo gak berhasil ya ulangi lagi hitung – hitung belajar PHP.😉 PORTAL ISENG

Comments»

No comments yet — be the first.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: