Skip to content
Snippets Groups Projects
Commit f4046082 authored by Arya Pradipta's avatar Arya Pradipta
Browse files

adding datetime in pengumuman

parent 21d2d87b
No related merge requests found
Pipeline #5194 passed with stages
in 8 minutes and 19 seconds
......@@ -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();
......@@ -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);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment