I have a function who get the date and value from API, but I want to change the date and time format on x axis on chart.js with MM-DD HH and time zone to UTC +2 (Bulgaria) with moment.js
The functions:
var mikeFWLabelChart = [], mikeFWDataChart = [];
async function mikeFWChart() {
await getMikeFWData()
//Create first chart
const ctx = document.getElementById('mikeFWChart');
new Chart(ctx, {
data: {
labels: mikeFWLabelChart,
datasets: [{
type: 'line',
label: 'Метра',
data: mikeFWDataChart,
borderWidth: 1
}]
},
options: {
scales: {
y: {
type: 'linear',
responsive: true,
maintainAspectRatio: false,
}
}
}
})
};
async function getMikeFWData() {
const apiUrl = "apiURL"
const response = await fetch(apiUrl)
const mikefwdata = await response.json()
const mikefwdate = mikefwdata.floodguard_mikefw.rows.map((x) => x.date)
//console.log(mikefwdate)
const mikefwvalue = mikefwdata.floodguard_mikefw.rows.map((x) => x.level)
//console.log(mikefwvalue)
mikeFWLabelChart = mikefwdate;
mikeFWDataChart = mikefwvalue;
}
The dates come with this format:
"2023-01-15T08:00:00.000Z"
How can I change mikefwdate
to this date format: (MM-DD HH) ?