l have data JSON coming from URL and l displayed those data in a table.
As you see l have different time dates. l want to add a new element above '12:15 am' to display the full date to make the user know that is a new day as the image below.
Code :
function airport() {
var airport_data = ""
$.ajax('my_airport.json', {
type: 'GET',
dataType: 'json',
timeout: 5000,
cache: false,
}).done(function (data, textStatus, jqXHR) {
data.forEach(element => {
if (element.flight.status.generic.status.text == 'scheduled') {
airport_data += '<tr>';
airport_data += '<td><p>' + element.flight.airline.name + '</p></td>';
airport_data += '<td><p>' + element.flight.identification.number.default + '</p></td>';
if (element.flight.aircraft == null) {
airport_data += '<td><p>N/A</p></td>';
} else {
airport_data += '<td><p>' + element.flight.aircraft.model.code + '</p></td>';
}
airport_data += '<td><p>' + element.flight.airport.origin.position.region.city + '</p></td>';
/// time is here
airport_data += '<td><p>' + moment.unix(element.flight.time.scheduled.arrival).format("h:mm a") + '</p></td>';
airport_data += '<td><p>' + element.flight.status.generic.status.text + '</p></td>';
if (!element.flight.time.scheduled.arrival) airport_data += "<tr><td><p>N/A</p></td></tr>";
}
document.getElementById("data").innerHTML = airport_data
var rows = $("#data");
rows.hide();
$('.row-data:last-child').after(rows);
rows.fadeIn(500);
});
})
}
html :
<div class="table-responsive">
<table class="table table-condensed text-center table-hover"">
<thead>
<tr>
<th>AIRLINES</th>
<th>CALLSIGN</th>
<th>TYPE</th>
<th>FROM</th>
<th>TIME</th>
<th>STATUS</th>
</tr>
</thead>
<tbody id="data" class="data">
</tbody>
</table>
</div>

