I am using PHP JSON as API in android. I am taking news from MYSQL data with below code. Its working fine but date format is showing as YYYY-MM-DD. But I want get it like DD-MM-YYYY. I have searched lot of but not found any solution. Can anybody here can solve my issue ?
<?php
$response = array();
require 'db.php';
$query = "SELECT * FROM news where order by id desc";
$result = mysqli_query($conn,$query);
if (mysqli_num_rows($result) > 0) {
$response["news"] = array();
while ($row = $result->fetch_assoc()) {
$news= array();
$news["id"] = $row["id"];
$news["title"] = $row["title"];
$news["description"] = $row["description"];
$news["news_date"] = $row["news_date"];
array_push($response["news"], $news);
}
$response["success"] = 1;
// echoing JSON response
//echo json_encode($response);
echo json_encode($response['news']);
} else {
$response["success"] = 0;
echo json_encode($response);
}
Thank