diff --git a/getAllBerita.php b/getAllBerita.php index 7889047bf42b1820273e76324642bbeca00b7683..b9581c87f8045d28b2da6082f7fa9320dfd93c19 100755 --- a/getAllBerita.php +++ b/getAllBerita.php @@ -10,13 +10,29 @@ * @link http://pear.php.net/package/komunitas-pmo */ +function tanggal_indo($tanggal) +{ + $hari = array ( 1 => 'Senin', 'Selasa', 'Rabu', 'Kamis', 'Jumat', 'Sabtu', 'Minggu'); + + $bulan = array (1 => 'Januari', 'Februari', 'Maret', 'April', 'Mei', 'Juni', 'Juli', 'Agustus', 'September', + 'Oktober', 'November', 'Desember'); + + $split = explode('-', $tanggal); + $tgl_indo = $split[2] . ' ' . $bulan[ (int)$split[1] ] . ' ' . $split[0]; + $num = date('N', strtotime($tanggal)); + return $hari[$num] . ', ' . $tgl_indo; +} + require 'dbConnect.php'; header('Content-Type: application/json'); $stmt = $conn->query("SELECT `id`, `judul`, `tgl`, `foto` FROM `berita`"); $count = $stmt->num_rows; $res = array(); + + while ($row = $stmt->fetch_assoc()) { + $row['tgl'] = tanggal_indo($row['tgl']); $fotoarray = json_decode($row["foto"]); $row["foto"] = $fotoarray[0]; $res[] = $row;