I'm not very experienced in ajax and having trouble formatting my date from a MySQL database.
I've tried using the php date() function but can't seem to get it to work properly. What would be the best way to format the date in this?
$(document).ready(function(){
$.ajax({
type: "GET",
url: "../api/presentation/read.php",
dataType: 'json',
success: function(data) {
var response="";
for(var user in data){
response += "<tr>"+
"<td>"+data[user].date+"</td>"+
"<td>"+data[user].title+"</td>"+
"<td>"+data[user].speaker+"</td>"+
"<td><a href='update.php?id="+data[user].id+"'>Edit</a> | <a href='#' onClick=Remove('"+data[user].id+"')>Remove</a> | <a href='#' onClick=Active('"+data[user].id+"')>Active</a></td>"+
"</tr>";
}
$(response).appendTo($("#presentations"));
}
});
});
I have tried something along the lines of
"<td><?php echo date("+data[user].date+",dd-mm); ?></td>"+
This gives an output of "+01am31am[00000000UTCThu, 01 Jan 1970 00:00:00 +0000].01am31UTC+" which I suspect is because no value is being given to the date function?
I'd like the output to be in the format of dd-mm HH-MM instead of the MySQL datetime format of "2019-10-29 10:00:00"
datefunction and what the desired result should be? Please add it to your question above.+characters. Do you want to add or use as a concatenate method?