Here I'm getting my date response and storedin local variable responsedata and mapped from customdata I want to cover that date coming from i.logs[0].datetime to local time string! just stored all data in apidata state so I can forward them as props. the main question in datetime here im getting a date in unix formate but i want to conver it into local time!!
useEffect(() => {
const postdata = {
api_key: apiKey,
format: "json",
logs: 1,
custom_uptime_ranges: "1658892600_1658979000-1658946600_1659033000",
};
const url = "https://api.uptimerobot.com/v2/getMonitors";
const getData = async () => {
await fetch(url, {
method: "POST",
body: JSON.stringify(postdata),
headers: { "Content-type": "application/json" },
}).then(async (response) => {
const responseData = await response.json();
const customData = responseData.monitors.map((i) => ({
title: i.friendly_name,
uptime: i.custom_uptime_ranges,
date: i.logs[0].datetime,
}));
console.log(responseData);
setApiData(customData);
console.log(apidata);
});
};
getData();
}, [apidata]);```