I am getting json from backend like this :
{
"datas":[
{
"id":4,
"create_date":"2021-03-18T21:11:57.239Z"
},
{
"id":5,
"create_date":"2021-03-19T19:37:05.829Z"
}
]
}
and looping through json like below :
$(data.datas).each(function(index,value){
html += `<tr><th scope="row">${index+1}</th>
<td>${value.id}</td>
<td>${value.create_date}</td>
<td><a href="#" class="btn btn-outline-dark">View Car</a></td>
</tr>`
})
But, here create_date
is just printing in td column like this 2021-03-18T21:11:57.239Z
. So, how can i make this display like this 2021-03-18 & 21:11 am/pm
in each tds ?
My attempt :
var created_date = value.create_date;
console.log(created_date.split("T")[0]);//2021-03-18
console.log(created_date.split("T")[1])//21:11:57.239Z (how can i remove 57.239Z..)
I am open for both solution i.e : backend as well as frontend . For my backend i am using django let me know if you need to see any code from backend .