From 65258b388842d7abe49872c0e8c633d9e0f47212 Mon Sep 17 00:00:00 2001
From: aryapradipta9 <aryapradipta9@gmail.com>
Date: Wed, 9 May 2018 13:10:43 +0700
Subject: [PATCH] fixing date

---
 getAllBerita.php | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/getAllBerita.php b/getAllBerita.php
index 7889047..b9581c8 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;
-- 
GitLab