I am attempting to display the date in the format "YYYY-MM-DD HH:mm", but when I try like this:
const formatDate = "YYYY-MM-DD HH:mm";
mikeFWLabelChart = moment(mikeFWLabelChart).format(formatDate);
const a = new Chart(canvasElement, {
data: {
labels: mikeFWLabelChart,
datasets: [{
type: 'line',
label: 'Метра',
data: mikeFWDataChart,
borderWidth: 1
}]
},
options: {
scales: {
xAxes: [{
type: "time",
time: {
format: formatDate,
tooltipFormat: 'll'
},
scaleLabel: {
display: true,
labelString: 'Date'
}
}],
yAxes: [{
scaleLabel: {
display: true,
labelString: 'value'
}
}]
}
}
})
};
I receive an error on the X axis INVALID DATE..
Also, I am trying to change the date format without using moment.js code:
mikeFWLabelChart = moment(mikeFWLabelChart).format(formatDate);
with options code -> format
But they still look like this format: 2023-02-16T05:00:00.000Z
How can I change the date format to YYYY-MM-DD HH:mm ?