diff --git a/getAllBerita.php b/getAllBerita.php index 45c24156588a90daa219b046196188fe10ba9a07..e55704f062f91ef1c6a3dfffdf634e3317bc4270 100755 --- a/getAllBerita.php +++ b/getAllBerita.php @@ -37,5 +37,5 @@ while ($row = $stmt->fetch_assoc()) { $row["foto"] = $fotoarray[0]; $res[] = $row; } -echo json_encode($res, JSON_PRETTY_PRINT); +echo json_encode($res); $conn->close(); diff --git a/getAllPengumuman.php b/getAllPengumuman.php index 1f2cbb00ddd2f508b839d92fa7f6f3c0798f799f..5826775060dae1d0ad83cdc2a5102d6820ad89d8 100755 --- a/getAllPengumuman.php +++ b/getAllPengumuman.php @@ -10,12 +10,30 @@ * @link http://pear.php.net/package/komunitas-pmo */ +function tanggal_indo($tanggal) +{ + $hari = array ( 1 => 'Sen', 'Sel', 'Rab', 'Kam', 'Jum', 'Sab', 'Min'); + + $bulan = array (1 => 'Jan', 'Feb', 'Mar', 'Apr', 'Mei', 'Jun', 'Jul', 'Agu', 'Sep', + 'Okt', 'Nov', 'Des'); + + $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 * FROM `pengumuman` ORDER BY `tanggal` DESC"); $count = $stmt->num_rows; $res = array(); while ($row = $stmt->fetch_assoc()) { + $fullTanggal = new DateTime($row['tanggal']); + $date = tanggal_indo(date_format($fullTanggal, "Y-m-d")); + $time = date_format($fullTanggal, "H:i"); + $row['tanggal'] = $date . ' ' . $time; $res[] = $row; } echo json_encode($res);