here I have a question regarding dates in javascript.
I have a problem, that is, when I console the results of my coding, the date output is like this..
My expectation is, after I ask here the output will be like this =
On 2023-01-02 there was 1 call api
*how do you make it from scratch like this, 2023-01-02T08:41:50.037Z to 2023-01-02 ?
Thank you*
Previously I had a data.json like the following =>
const data = [
{
"host": "10.4.3.121",
"port": 53352,
"@version": "1",
"user": "63edd591-77b6-427b-ab85-97f5b9e21421",
"@timestamp": "2023-01-02T08:41:50.037Z",
"type": "production",
"data": {
"context": "nad/v1/getGeopoiByKelurahan",
"status": 200,
"level": "info",
"params": {
"provinsi": "DKI JAKARTA",
"kota": "KOTA JAKARTA PUSAT",
"category": "School",
"kecamatan": "GAMBIR"
},
"price": 0,
"scope": "Processing query",
"message": "getPoiByKelurahan"
},
"score": 2
},
]
//
Then the code is like this =>
const result = Object.values(data.reduce((acc, curr) => {
if (acc[curr["@timestamp"]] == null) {
acc[curr["@timestamp"]] = { message: curr.message, timestamp: curr["@timestamp"], count: 0 };
}
acc[curr["@timestamp"]].count++;
return acc;
}, {}));
result.forEach(item => {
console.log(`Pada tanggal ${item.timestamp} terjadi ${item.count}x call api`)
});